adjust smtp configs
This commit is contained in:
@@ -86,7 +86,7 @@ Rails.application.configure do
|
|||||||
user_name: ENV.fetch('SMTP_USERNAME', nil),
|
user_name: ENV.fetch('SMTP_USERNAME', nil),
|
||||||
password: ENV.fetch('SMTP_PASSWORD', nil),
|
password: ENV.fetch('SMTP_PASSWORD', nil),
|
||||||
authentication: ENV.fetch('SMTP_PASSWORD', nil).present? ? ENV.fetch('SMTP_AUTHENTICATION', 'plain') : nil,
|
authentication: ENV.fetch('SMTP_PASSWORD', nil).present? ? ENV.fetch('SMTP_AUTHENTICATION', 'plain') : nil,
|
||||||
enable_starttls_auto: ENV['SMTP_ENABLE_STARTTLS_AUTO'] != 'false'
|
enable_starttls: ENV['SMTP_ENABLE_STARTTLS'] != 'false'
|
||||||
}.compact
|
}.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ module ActionMailerConfigsInterceptor
|
|||||||
def build_smtp_configs_hash(email_configs)
|
def build_smtp_configs_hash(email_configs)
|
||||||
value = email_configs.value
|
value = email_configs.value
|
||||||
|
|
||||||
|
is_tls = value['security'] == 'tls' || (value['security'].blank? && value['port'].to_s == '465')
|
||||||
|
is_ssl = value['security'] == 'ssl'
|
||||||
|
|
||||||
{
|
{
|
||||||
user_name: value['username'],
|
user_name: value['username'],
|
||||||
password: value['password'],
|
password: value['password'],
|
||||||
@@ -53,11 +56,11 @@ module ActionMailerConfigsInterceptor
|
|||||||
domain: value['domain'],
|
domain: value['domain'],
|
||||||
openssl_verify_mode: value['security'] == 'noverify' ? OpenSSL::SSL::VERIFY_NONE : nil,
|
openssl_verify_mode: value['security'] == 'noverify' ? OpenSSL::SSL::VERIFY_NONE : nil,
|
||||||
authentication: value['password'].present? ? value.fetch('authentication', 'plain') : nil,
|
authentication: value['password'].present? ? value.fetch('authentication', 'plain') : nil,
|
||||||
enable_starttls_auto: value['security'] != 'tls',
|
enable_starttls: !is_tls && !is_ssl,
|
||||||
open_timeout: OPEN_TIMEOUT,
|
open_timeout: OPEN_TIMEOUT,
|
||||||
read_timeout: READ_TIMEOUT,
|
read_timeout: READ_TIMEOUT,
|
||||||
ssl: value['security'] == 'ssl',
|
ssl: is_ssl,
|
||||||
tls: value['security'] == 'tls' || (value['security'].blank? && value['port'].to_s == '465')
|
tls: is_tls
|
||||||
}.compact_blank
|
}.compact_blank
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user