Skip to content

Commit

Permalink
SMTP: Allow for NOAUTH (#2079)
Browse files Browse the repository at this point in the history
* SMTP: Allow for NOAUTH

* Also remove defaults for open_timeout, read_timeout and enable_starttls_auto
  • Loading branch information
pglombardo authored Apr 24, 2024
1 parent 7427d32 commit 755f694
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 30 deletions.
19 changes: 11 additions & 8 deletions config/defaults/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -733,14 +733,6 @@ mail:
# Environment Variable Override: PWP__MAIL__SMTP_ADDRESS='smtp.example.com'
# smtp_address: smtp.example.com

# If your mail server requires authentication, set the username in this setting.
# Environment Variable Override: PWP__MAIL__SMTP_USER_NAME='apikey'
# smtp_user_name: 'apikey'

# If your mail server requires authentication, set the password in this setting.
# 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: ''
Expand All @@ -755,9 +747,20 @@ mail:
# or :cram_md5 (combines a Challenge/Response mechanism to exchange
# information and a cryptographic Message Digest 5 algorithm to hash
# important information)
#
# Important: Comment this out if your server doesn't require authentication.
#
# Environment Variable Override: PWP__MAIL__SMTP_AUTHENTICATION='plain'
smtp_authentication: 'plain'

# If your mail server requires authentication, set the username in this setting.
# Environment Variable Override: PWP__MAIL__SMTP_USER_NAME='apikey'
# smtp_user_name: 'apikey'

# If your mail server requires authentication, set the password in this setting.
# Environment Variable Override: PWP__MAIL__SMTP_PASSWORD='something@&#$'
# smtp_password: ''

# Use STARTTLS when connecting to your SMTP server and fail if unsupported.
# Environment Variable Override: PWP__MAIL__SMTP_STARTTLS='true'
# smtp_starttls: false
Expand Down
26 changes: 19 additions & 7 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,33 @@

config.action_mailer.smtp_settings = {
address: Settings.mail.smtp_address,
port: Settings.mail.smtp_port,
user_name: Settings.mail.smtp_user_name,
password: Settings.mail.smtp_password,
authentication: Settings.mail.smtp_authentication,
enable_starttls_auto: Settings.mail.smtp_enable_starttls_auto,
open_timeout: Settings.mail.smtp_open_timeout,
read_timeout: Settings.mail.smtp_read_timeout
port: Settings.mail.smtp_port
}

config.action_mailer.smtp_settings[:domain] = Settings.mail.smtp_domain if Settings.mail.smtp_domain
config.action_mailer.smtp_settings[:open_timeout] = Settings.mail.smtp_open_timeout if Settings.mail.smtp_open_timeout
config.action_mailer.smtp_settings[:read_timeout] = Settings.mail.smtp_read_timeout if Settings.mail.smtp_read_timeout

if Settings.mail.smtp_authentication
config.action_mailer.smtp_settings[:authentication] = Settings.mail.smtp_authentication
end

if Settings.mail.smtp_user_name
config.action_mailer.smtp_settings[:user_name] = Settings.mail.smtp_user_name
end

if Settings.mail.smtp_password
config.action_mailer.smtp_settings[:password] = Settings.mail.smtp_password
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_auto
config.action_mailer.smtp_settings[:enable_starttls_auto] = Settings.mail.smtp_enable_starttls_auto
end

if Settings.mail.smtp_enable_starttls
config.action_mailer.smtp_settings[:enable_starttls] = Settings.mail.smtp_enable_starttls
end
Expand Down
26 changes: 19 additions & 7 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,33 @@

config.action_mailer.smtp_settings = {
address: Settings.mail.smtp_address,
port: Settings.mail.smtp_port,
user_name: Settings.mail.smtp_user_name,
password: Settings.mail.smtp_password,
authentication: Settings.mail.smtp_authentication,
enable_starttls_auto: Settings.mail.smtp_enable_starttls_auto,
open_timeout: Settings.mail.smtp_open_timeout,
read_timeout: Settings.mail.smtp_read_timeout
port: Settings.mail.smtp_port
}

config.action_mailer.smtp_settings[:domain] = Settings.mail.smtp_domain if Settings.mail.smtp_domain
config.action_mailer.smtp_settings[:open_timeout] = Settings.mail.smtp_open_timeout if Settings.mail.smtp_open_timeout
config.action_mailer.smtp_settings[:read_timeout] = Settings.mail.smtp_read_timeout if Settings.mail.smtp_read_timeout

if Settings.mail.smtp_authentication
config.action_mailer.smtp_settings[:authentication] = Settings.mail.smtp_authentication
end

if Settings.mail.smtp_user_name
config.action_mailer.smtp_settings[:user_name] = Settings.mail.smtp_user_name
end

if Settings.mail.smtp_password
config.action_mailer.smtp_settings[:password] = Settings.mail.smtp_password
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_auto
config.action_mailer.smtp_settings[:enable_starttls_auto] = Settings.mail.smtp_enable_starttls_auto
end

if Settings.mail.smtp_enable_starttls
config.action_mailer.smtp_settings[:enable_starttls] = Settings.mail.smtp_enable_starttls
end
Expand Down
19 changes: 11 additions & 8 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -733,14 +733,6 @@ mail:
# Environment Variable Override: PWP__MAIL__SMTP_ADDRESS='smtp.example.com'
# smtp_address: smtp.example.com

# If your mail server requires authentication, set the username in this setting.
# Environment Variable Override: PWP__MAIL__SMTP_USER_NAME='apikey'
# smtp_user_name: 'apikey'

# If your mail server requires authentication, set the password in this setting.
# 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: ''
Expand All @@ -755,9 +747,20 @@ mail:
# or :cram_md5 (combines a Challenge/Response mechanism to exchange
# information and a cryptographic Message Digest 5 algorithm to hash
# important information)
#
# Important: Comment this out if your server doesn't require authentication.
#
# Environment Variable Override: PWP__MAIL__SMTP_AUTHENTICATION='plain'
smtp_authentication: 'plain'

# If your mail server requires authentication, set the username in this setting.
# Environment Variable Override: PWP__MAIL__SMTP_USER_NAME='apikey'
# smtp_user_name: 'apikey'

# If your mail server requires authentication, set the password in this setting.
# Environment Variable Override: PWP__MAIL__SMTP_PASSWORD='something@&#$'
# smtp_password: ''

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

0 comments on commit 755f694

Please sign in to comment.