mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 18:42:45 +08:00
Allow to set SMTP settings via environment variable.
This commit is contained in:
parent
4f32b8a9ae
commit
a7b8481c8f
|
@ -40,8 +40,27 @@ Discourse::Application.configure do
|
|||
# :authentication => 'plain',
|
||||
# :enable_starttls_auto => true }
|
||||
|
||||
config.action_mailer.delivery_method = :sendmail
|
||||
config.action_mailer.sendmail_settings = {arguments: '-i'}
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user