]> cat aescling's git repositories - mastodon.git/commitdiff
Set default From address in config (#3756)
authorAkihiko Odaki (@fn_aki@pawoo.net) <akihiko.odaki.4i@stu.hosei.ac.jp>
Thu, 6 Jul 2017 22:12:12 +0000 (07:12 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Thu, 6 Jul 2017 22:12:12 +0000 (00:12 +0200)
The old implementation sets default From address in mailers. It sets
the address from SMTP_FROM_ADDRESS, or notifications@localhost. The
behavior is occasionally undesired results.

In production environment, notifications@localhost is likely to be
incorrect.
In testing environment, the email address should not be varied by a
environment variable.

After appling this change,

In production environment, it will throw an exception when launching
Mastodon.
In testing environment, the address will be fixed with
notifications@localhost.

app/mailers/application_mailer.rb
app/mailers/user_mailer.rb
config/environments/development.rb
config/environments/production.rb
config/environments/test.rb

index 2e730c19b0433b4a3a25b9e2fe75a174426a04e7..95b770ff111d0703fd9677025511c91d93667606 100644 (file)
@@ -1,7 +1,6 @@
 # frozen_string_literal: true
 
 class ApplicationMailer < ActionMailer::Base
-  default from: ENV.fetch('SMTP_FROM_ADDRESS') { 'notifications@localhost' }
   layout 'mailer'
   helper :instance
 
index 6abf9c9caffef9e537e6315fab582caff6da85b3..1517c027e87b8bb1873212e435094444fcb9211f 100644 (file)
@@ -1,7 +1,6 @@
 # frozen_string_literal: true
 
 class UserMailer < Devise::Mailer
-  default from: ENV.fetch('SMTP_FROM_ADDRESS') { 'notifications@localhost' }
   layout 'mailer'
 
   helper :instance
index c81cf7bbedda3342e9f27b6ba56b46a4ab29532b..406fa970b2db29a17e73b107f16635c2f6f74398 100644 (file)
@@ -62,6 +62,8 @@ Rails.application.configure do
   # routes, locales, etc. This feature depends on the listen gem.
   # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
 
+  config.action_mailer.default_options = { from: 'notifications@localhost' }
+
   # If using a Heroku, Vagrant or generic remote development environment,
   # use letter_opener_web, accessible at  /letter_opener.
   # Otherwise, use letter_opener, which launches a browser window to view sent mail.
index bd87d79a7856362534b4c92123c544f6fcb9f85c..d9c9da684fd7b765abe1fe0be8fab507ce065225 100644 (file)
@@ -73,6 +73,8 @@ Rails.application.configure do
   config.action_mailer.perform_caching = false
 
   # E-mails
+  config.action_mailer.default_options = { from: ENV.fetch('SMTP_FROM_ADDRESS') }
+
   config.action_mailer.smtp_settings = {
     :port                 => ENV['SMTP_PORT'],
     :address              => ENV['SMTP_SERVER'],
index db98263a64a935a457b26a1825768064f56b6745..bde69eba15a644a433f37c7ad57051ecf4803f1f 100644 (file)
@@ -30,6 +30,8 @@ Rails.application.configure do
   config.action_controller.allow_forgery_protection = false
   config.action_mailer.perform_caching = false
 
+  config.action_mailer.default_options = { from: 'notifications@localhost' }
+
   # Tell Action Mailer not to deliver emails to the real world.
   # The :test delivery method accumulates sent emails in the
   # ActionMailer::Base.deliveries array.