From 00ad509c3a2e400e618ac2dfd1f3551b7c286abc Mon Sep 17 00:00:00 2001 From: Molly Struve Date: Mon, 24 Aug 2020 14:20:50 -0500 Subject: [PATCH] [deploy] Update Sendgrid to Use API Key if Present (#9981) --- config/environments/production.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index e604737ec..58ee960fa 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -115,13 +115,14 @@ Rails.application.configure do config.action_mailer.delivery_method = :smtp config.action_mailer.perform_deliveries = true + sendgrid_api_key_present = ENV["SENDGRID_API_KEY"].present? config.action_mailer.default_url_options = { host: protocol + config.app_domain } ActionMailer::Base.smtp_settings = { address: "smtp.sendgrid.net", port: "587", authentication: :plain, - user_name: ENV["SENDGRID_USERNAME_ACCEL"], - password: ENV["SENDGRID_PASSWORD_ACCEL"], + user_name: sendgrid_api_key_present ? "apikey" : ENV["SENDGRID_USERNAME_ACCEL"], + password: sendgrid_api_key_present ? ENV["SENDGRID_API_KEY"] : ENV["SENDGRID_PASSWORD_ACCEL"], domain: ENV["APP_DOMAIN"], enable_starttls_auto: true }