From 2e54a159f89f44de02630b9f9291799d838c7bd9 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 9 Dec 2018 08:06:27 +0500 Subject: [PATCH] Add file "config/smtp.yml" --- .../action_mailer_smtp_settings.rb | 21 +++++++++++-------- config/smtp.yml | 9 ++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 config/smtp.yml diff --git a/config/initializers/action_mailer_smtp_settings.rb b/config/initializers/action_mailer_smtp_settings.rb index 42e8cb3..d3ddae9 100644 --- a/config/initializers/action_mailer_smtp_settings.rb +++ b/config/initializers/action_mailer_smtp_settings.rb @@ -2,12 +2,15 @@ # Be sure to restart your server when you modify this file. -ActionMailer::Base.smtp_settings = { - user_name: 'apikey', - password: Rails.application.credentials.sendgrid_api_key, - domain: Rails.application.config.site_domain, - address: 'smtp.sendgrid.net', - port: 587, - authentication: :plain, - enable_starttls_auto: true, -} +Rails.application.config_for(:smtp).try(&:deep_symbolize_keys).try do |config| + ActionMailer::Base.smtp_settings = { + address: config[:address], + port: config[:port]&.to_i, + domain: config[:domain], + user_name: config[:user_name], + password: config[:password], + authentication: config[:authentication]&.to_sym, + enable_starttls_auto: config[:enable_starttls_auto], + openssl_verify_mode: config[:openssl_verify_mode], + } +end diff --git a/config/smtp.yml b/config/smtp.yml new file mode 100644 index 0000000..ec18c64 --- /dev/null +++ b/config/smtp.yml @@ -0,0 +1,9 @@ +production: + address: smtp.sendgrid.net + port: 587 + domain: libertarian-party.com + user_name: apikey + password: <%= Rails.application.credentials.sendgrid_api_key %> + authentication: plain + enable_starttls_auto: true + openssl_verify_mode: peer