Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SMTP credentials optional which is required by sSMTP #294

Merged
merged 1 commit into from Jan 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions config/environments/production.rb
Expand Up @@ -67,11 +67,11 @@
}

config.action_mailer.smtp_settings = {
address: ENV.fetch('SMTP_ADDRESS'),
port: ENV.fetch('SMTP_PORT'),
user_name: ENV.fetch('SMTP_USERNAME'),
password: ENV.fetch('SMTP_PASSWORD'),
authentication: ENV.fetch('SMTP_AUTHENTICATION_TYPE'),
address: ENV['SMTP_ADDRESS'],
port: ENV['SMTP_PORT'],
user_name: ENV['SMTP_USERNAME'],
password: ENV['SMTP_PASSWORD'],
authentication: ENV['SMTP_AUTHENTICATION_TYPE'],
domain: ENV['SMTP_DOMAIN'],
ssl: ENV['SMTP_USE_SSL'],
tls: ENV['SMTP_USE_TLS'],
Expand All @@ -81,6 +81,7 @@
open_timeout: ENV['SMTP_OPEN_TIMEOUT'],
read_timeout: ENV['SMTP_READ_TIMEOUT']
}.compact.tap do |options|

# Typecast several options to integers.
%i[ port open_timeout read_timeout ].each do |option|
options[option] = options[option].to_i if options.key?(option)
Expand All @@ -90,7 +91,9 @@
%i[ ssl tls enable_starttls enable_starttls_auto ].each do |option|
options[option] = !!options[option] if options.key?(option)
end
end

# Enable mailer only if variables are defined in environment.
end if ENV.key?('SMTP_ADDRESS') && ENV.key?('SMTP_PORT')

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
Expand Down