Skip to content

Commit

Permalink
Add extended SMTP config options (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
pglombardo authored Aug 26, 2022
1 parent 9263651 commit 3d1e909
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 4 deletions.
14 changes: 13 additions & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,23 @@
user_name: Settings.mail.smtp_user_name,
password: Settings.mail.smtp_password,
authentication: Settings.mail.smtp_authentication,
enable_starttls_auto: Settings.mail.smtp_starttls,
enable_starttls_auto: Settings.mail.smtp_enable_starttls_auto,
open_timeout: Settings.mail.smtp_open_timeout,
read_timeout: Settings.mail.smtp_read_timeout
}

if Settings.mail.smtp_domain
config.action_mailer.smtp_settings[:domain] = Settings.mail.smtp_domain
end

if Settings.mail.smtp_openssl_verify_mode
config.action_mailer.smtp_settings[:openssl_verify_mode] = Settings.mail.smtp_openssl_verify_mode.to_sym
end

if Settings.mail.smtp_enable_starttls
config.action_mailer.smtp_settings[:enable_starttls] = Settings.mail.smtp_enable_starttls
end

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log

Expand Down
14 changes: 13 additions & 1 deletion config/environments/private.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,20 @@
user_name: Settings.mail.smtp_user_name,
password: Settings.mail.smtp_password,
authentication: Settings.mail.smtp_authentication,
enable_starttls_auto: Settings.mail.smtp_starttls,
enable_starttls_auto: Settings.mail.smtp_enable_starttls_auto,
open_timeout: Settings.mail.smtp_open_timeout,
read_timeout: Settings.mail.smtp_read_timeout
}

if Settings.mail.smtp_domain
config.action_mailer.smtp_settings[:domain] = Settings.mail.smtp_domain
end

if Settings.mail.smtp_openssl_verify_mode
config.action_mailer.smtp_settings[:openssl_verify_mode] = Settings.mail.smtp_openssl_verify_mode.to_sym
end

if Settings.mail.smtp_enable_starttls
config.action_mailer.smtp_settings[:enable_starttls] = Settings.mail.smtp_enable_starttls
end
end
14 changes: 13 additions & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,23 @@
user_name: Settings.mail.smtp_user_name,
password: Settings.mail.smtp_password,
authentication: Settings.mail.smtp_authentication,
enable_starttls_auto: Settings.mail.smtp_starttls,
enable_starttls_auto: Settings.mail.smtp_enable_starttls_auto,
open_timeout: Settings.mail.smtp_open_timeout,
read_timeout: Settings.mail.smtp_read_timeout
}

if Settings.mail.smtp_domain
config.action_mailer.smtp_settings[:domain] = Settings.mail.smtp_domain
end

if Settings.mail.smtp_openssl_verify_mode
config.action_mailer.smtp_settings[:openssl_verify_mode] = Settings.mail.smtp_openssl_verify_mode.to_sym
end

if Settings.mail.smtp_enable_starttls
config.action_mailer.smtp_settings[:enable_starttls] = Settings.mail.smtp_enable_starttls
end

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
Expand Down
21 changes: 20 additions & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ throttling:
# for things such as forgot password, unlock account, confirm account etc.
# If `enable_logins` is set to true above, the following _are required_ to be
# filled out with valid values.
#
# These values are passed through to ActionMailer configuration. The documentation
# for ActionMailer is at:
# https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration
#
mail:
# Email delivery errors will be shown in the application
# Environment Variable Override: PWP__MAIL__RAISE_DELIVERY_ERRORS='false'
Expand All @@ -202,6 +207,10 @@ mail:
# Environment Variable Override: PWP__MAIL__SMTP_PASSWORD='something@&#$'
# smtp_password: ''

# If you need to specify a HELO domain, you can do it here.
# Environment Variable Override: PWP__MAIL__SMTP_DOMAIN='xyz.dev'
# smtp_domain: ''

# Port of the SMTP server
# Environment Variable Override: PWP__MAIL__SMTP_PORT='587'
smtp_port: 587
Expand All @@ -217,7 +226,11 @@ mail:

# Use STARTTLS when connecting to your SMTP server and fail if unsupported.
# Environment Variable Override: PWP__MAIL__SMTP_STARTTLS='true'
smtp_starttls: true
# smtp_starttls: false

# Detects if STARTTLS is enabled in your SMTP server and starts to use it. Defaults to true.
# Environment Variable Override: PWP__MAIL__SMTP_ENABLE_STARTTLS_AUTO='false'
smtp_enable_starttls_auto: true

# Number of seconds to wait while attempting to open a connection.
# Environment Variable Override: PWP__MAIL__SMTP_OPEN_TIMEOUT='10'
Expand All @@ -227,6 +240,12 @@ mail:
# Environment Variable Override: PWP__MAIL__SMTP_READ_TIMEOUT='10'
smtp_read_timeout: 10

# When using TLS, you can set how OpenSSL checks the certificate. This is
# useful if you need to validate a self-signed and/or a wildcard certificate.
# This can be one of the OpenSSL verify constants, :none or :peer
# Environment Variable Override: PWP__MAIL__SMTP_OPENSSL_VERIFY_MODE='none'
# smtp_openssl_verify_mode: 'peer'

# Configure the e-mail address which will be shown as 'From' in emails
# See config/initializers/devise.rb where this is used
# Environment Variable Override: PWP__MAIL__MAILER_SENDER='"Password Pusher" <[email protected]>'
Expand Down

0 comments on commit 3d1e909

Please sign in to comment.