Allow to set SMTP settings via environment variable.

This commit is contained in:
Cyril Rohr 2013-10-08 15:48:57 +01:00
parent 4f32b8a9ae
commit a7b8481c8f

View File

@ -40,8 +40,27 @@ Discourse::Application.configure do
# :authentication => 'plain',
# :enable_starttls_auto => true }
if ENV.key?('SMTP_URL')
config.action_mailer.smtp_settings = begin
uri = URI.parse(ENV['SMTP_URL'])
params = {
:address => uri.host,
:port => uri.port,
:domain => (uri.path || "").split("/")[1],
:user_name => uri.user,
:password => uri.password,
:authentication => 'plain',
:enable_starttls_auto => true
}
CGI.parse(uri.query || "").each {|k,v| params[k.to_sym] = v.first}
params
rescue
raise "Invalid SMTP_URL"
end
else
config.action_mailer.delivery_method = :sendmail
config.action_mailer.sendmail_settings = {arguments: '-i'}
end
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify