Commit bee368cc authored by paz's avatar paz
Browse files

Enable more smtp_settings. Respect previous config-keys.

Now smtp_settings is a hash in our config, which is passed on to
Mail. smtp_host, smtp_port, and smtp_helo_domain are merged in.
parent 0aa36657
......@@ -3,8 +3,16 @@ superadmin: root@localhost
lists_dir: /var/schleuder/lists
plugins_dir: /etc/schleuder/plugins
log_level: warn
smtp_host: localhost
smtp_port: 25
smtp_settings:
# For explanation see documentation for ActionMailer::smtp_settings, e.g. <http://api.rubyonrails.org/classes/ActionMailer/Base.html>.
host: localhost
port: 25
#domain:
#enable_starttls_auto:
#openssl_verify_mode:
#authentication:
#user_name:
#password:
database:
production:
adapter: 'sqlite3'
......
......@@ -63,12 +63,7 @@ ActiveRecord::Base.establish_connection(Schleuder::Conf.databases[ENV["SCHLEUDER
ActiveRecord::Base.logger = Schleuder.logger
Mail.defaults do
delivery_method :smtp,
{
address: Schleuder::Conf.smtp_host,
port: Schleuder::Conf.smtp_port,
domain: Schleuder::Conf.smtp_helo_domain
}
delivery_method :smtp, Schleuder::Conf.smtp_settings
end
I18n.load_path += Dir[rootdir.to_s + "/locales/*.yml"]
......
......@@ -34,16 +34,33 @@ module Schleuder
instance.config['log_level'] || 'WARN'
end
# Three legacy options
def self.smtp_host
instance.config['smtp_host'] || 'localhost'
instance.config['smtp_host']
end
def self.smtp_port
instance.config['smtp_port'] || 25
instance.config['smtp_port']
end
def self.smtp_helo_domain
instance.config['smtp_helo_domain'] || 'localhost'
instance.config['smtp_helo_domain']
end
def self.smtp_settings
settings = instance.config['smtp_settings'] || {}
# Support previously used config-options.
# Remove this in future versions.
%w[smtp_host smtp_port smtp_helo_domain].each do |word|
value = self.send(word)
if value.present?
key = word.to_s.strip.gsub(/^smtp_(.*)$/, '\1')
Schleuder.logger.warn "Deprecation warning: In schleuder.yml #{word} should be changed to smtp_settings[#{key}]."
settings[key] = value
end
end
settings
end
private
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment