From db6713c124e789079e9c4f145eb042c1f4d9ae0d Mon Sep 17 00:00:00 2001 From: Matt Scilipoti Date: Mon, 19 Dec 2016 12:06:31 -0500 Subject: [PATCH 1/2] smtp config: support additional ssl related keys - smtp_enable_starttls_auto, smtp_openssl_verify_mode --- config/initializers/action_mailer.rb | 14 ++++++++------ config/load.rb | 2 ++ spec/initializers/action_mailer_spec.rb | 16 ++++++++++------ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/config/initializers/action_mailer.rb b/config/initializers/action_mailer.rb index 036d07efe..4728504a5 100644 --- a/config/initializers/action_mailer.rb +++ b/config/initializers/action_mailer.rb @@ -2,12 +2,14 @@ if Errbit::Config.email_delivery_method == :smtp ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = { - address: Errbit::Config.smtp_address, - port: Errbit::Config.smtp_port, - authentication: Errbit::Config.smtp_authentication, - user_name: Errbit::Config.smtp_user_name, - password: Errbit::Config.smtp_password, - domain: Errbit::Config.smtp_domain + address: Errbit::Config.smtp_address, + port: Errbit::Config.smtp_port, + authentication: Errbit::Config.smtp_authentication, + user_name: Errbit::Config.smtp_user_name, + password: Errbit::Config.smtp_password, + domain: Errbit::Config.smtp_domain, + enable_starttls_auto: Errbit::Config.smtp_enable_starttls_auto, + openssl_verify_mode: Errbit::Config.smtp_openssl_verify_mode } end diff --git a/config/load.rb b/config/load.rb index e3789a6e2..adeb61c19 100644 --- a/config/load.rb +++ b/config/load.rb @@ -53,6 +53,8 @@ smtp_address: ['SMTP_SERVER'], smtp_port: ['SMTP_PORT'], smtp_authentication: ['SMTP_AUTHENTICATION'], + smtp_enable_starttls_auto: ['SMTP_ENABLE_STARTTLS_AUTO'], + smtp_openssl_verify_mode: ['SMTP_OPENSSL_VERIFY_MODE'], smtp_user_name: %w(SMTP_USERNAME SENDGRID_USERNAME), smtp_password: %w(SMTP_PASSWORD SENDGRID_PASSWORD), smtp_domain: ['SMTP_DOMAIN', 'SENDGRID_DOMAIN', lambda do |values| diff --git a/spec/initializers/action_mailer_spec.rb b/spec/initializers/action_mailer_spec.rb index c74f61da7..9472e5e32 100644 --- a/spec/initializers/action_mailer_spec.rb +++ b/spec/initializers/action_mailer_spec.rb @@ -32,15 +32,19 @@ def load_initializer allow(Errbit::Config).to receive(:smtp_user_name).and_return('my-username') allow(Errbit::Config).to receive(:smtp_password).and_return('my-password') allow(Errbit::Config).to receive(:smtp_domain).and_return('someotherdomain.com') + allow(Errbit::Config).to receive(:smtp_enable_starttls_auto).and_return(true) + allow(Errbit::Config).to receive(:smtp_openssl_verify_mode).and_return('peer') load_initializer expect(ActionMailer::Base.smtp_settings).to eq( - address: 'smtp.somedomain.com', - port: 998, - authentication: :login, - user_name: 'my-username', - password: 'my-password', - domain: 'someotherdomain.com' + address: 'smtp.somedomain.com', + port: 998, + authentication: :login, + user_name: 'my-username', + password: 'my-password', + domain: 'someotherdomain.com', + enable_starttls_auto: true, + openssl_verify_mode: 'peer' ) end end From 0d4b9ed7ba68d4c9801158f694bd71d0b86fc24a Mon Sep 17 00:00:00 2001 From: Matt Scilipoti Date: Mon, 19 Dec 2016 12:19:31 -0500 Subject: [PATCH 2/2] smtp config: updated config docs with new settings - SMTP_ENABLE_STARTTLS_AUTO, SMTP_OPENSSL_VERIFY_MODE --- docs/configuration.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index 50911b943..fb331fbf2 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -103,6 +103,10 @@ In order of precedence Errbit uses:
Password for SMTP auth, you could also set SENDGRID_PASSWORD
SMTP_DOMAIN
HELO domain to set for outgoing SMTP messages, you can also use SENDGRID_DOMAIN +
SMTP_ENABLE_STARTTLS_AUTO +
Detects if STARTTLS is enabled in your SMTP server and starts to use it +
SMTP_OPENSSL_VERIFY_MODE +
When using TLS, you can set how OpenSSL checks the certificate. This is really useful if you need to validate a self-signed and/or a wildcard certificate. You can use the name of an OpenSSL verify constant ('none', 'peer', 'client_once', 'fail_if_no_peer_cert').
SENDMAIL_LOCATION
Path to sendmail
SENDMAIL_ARGUMENTS