about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-04-19 18:41:29 +0200
committerGitHub <noreply@github.com>2021-04-19 18:41:29 +0200
commit1efcbb9cfe36d4428ef6af988bb0d7b25ace3971 (patch)
treeeb30e581704eb2056cf00abbe44c11b8a84e1479
parent5b384d1a26b3fda5dda4fa61e4b29d7d07c02ec8 (diff)
Add Message-ID header to outgoing emails (#16076)
* Add Message-ID header to outgoing emails

* Use email domain name from SMTP_FROM_ADDRESS, fallback on WEB_DOMAIN on failure

* Use notifications@localhost as fallback for SMTP_FROM_ADDRESS, do not catch parse errors
-rw-r--r--config/environments/production.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 22be14749..df6b07d77 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -90,9 +90,12 @@ Rails.application.configure do
   config.action_mailer.perform_caching = false
 
   # E-mails
+  outgoing_email_address = ENV.fetch('SMTP_FROM_ADDRESS', 'notifications@localhost')
+  outgoing_mail_domain   = Mail::Address.new(outgoing_email_address).domain
   config.action_mailer.default_options = {
-    from: ENV.fetch('SMTP_FROM_ADDRESS', 'notifications@localhost'),
-    reply_to: ENV['SMTP_REPLY_TO']
+    from: outgoing_email_address,
+    reply_to: ENV['SMTP_REPLY_TO'],
+    'Message-ID': -> { "<#{Mail.random_tag}@#{outgoing_mail_domain}>" },
   }
 
   config.action_mailer.smtp_settings = {