From 53a52d92dda3ae2926bead93c7b14f34e4a43390 Mon Sep 17 00:00:00 2001 From: Sami Chakroun Date: Wed, 31 Jul 2019 19:16:00 +0200 Subject: [PATCH] Add email development config --- config/environments/development.rb | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 9f25028..d07ecc0 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -55,15 +55,23 @@ #Devise config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } - # ActionMailer::Base.smtp_settings = { - # user_name: ENV["SENDGRID_USERNAME"], - # password: ENV["SENDGRID_PASSWORD"], - # domain: "em1678.mail.chakroun.eu", - # address: "smtp.sendgrid.net", - # port: 587, - # authentication: :plain, - # enable_starttls_auto: true - # } + if ENV["ENABLE_DEV_EMAILS"] == "true" + ActionMailer::Base.smtp_settings = { + user_name: ENV["SENDGRID_USERNAME"], + password: ENV["SENDGRID_PASSWORD"], + domain: "em1678.mail.chakroun.eu", + address: "smtp.sendgrid.net", + port: 587, + authentication: :plain, + enable_starttls_auto: true + } + end + class SandboxEmailInterceptor + def self.delivering_email(message) + message.to = [ENV["DEVELOPER_EMAIL"]] + end + end + ActionMailer::Base.register_interceptor(SandboxEmailInterceptor) config.backup_with_callback = true