Rails4,异常通知程序未更改 sender_address

Rails4, Exception Notifier not change sender_address

我们的 Rails 应用程序使用 ExceptionNotifier Gem

并更改配置文件

异常邮件运行良好

但是发件人邮件不是Noreply < noreply@our_domain.com >

发件人总是我的 email_address

我的 production.rb 文件是

config.log_formatter = ::Logger::Formatter.new

config.middleware.use ExceptionNotification::Rack,
   :email => {
     :email_prefix => "[Exception ",
     :sender_address => %{"Noreply" <noreply@our_domain.com>},
     :exception_recipients => %w{my_email@gmail.com}
   }   

而 setup_mailer.rb 文件是

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.smtp_settings = {
  :address => "smtp.gmail.com",
  :port => 587,
  :domain => "our_domain.com",
  :user_name => "my_eamail@our_domain.com",
  :password => "PASSWORD",
  :authentication => "login",
  :enable_starttls_auto => true

} 

为什么发件人地址没有改变???

如果您使用 Gmail SMTP 帐户进行身份验证,Gmail 会将发件人覆盖到您的 Gmail 帐户。他们不允许您使用他们的 SMTP 从不同的域发送电子邮件。

尝试下面的代码 production.rb(假设你想在生产中工作)和 硬编码 它....

 ##added exception notification gem
 MyApp::Application.config.middleware.use ExceptionNotification::Rack,
   :email => {
     :email_prefix => "[MyApp_Error] ",
     :sender_address => %{"notifier" <notifier@myApp.com>},
     :exception_recipients => %w{your_desired_email@gmail.com}
   }

我为我工作....

#TRY THIS in :sender_address 写下你自己的姓名和邮件地址

 :sender_address => %{"Username" <useremailid@xyzmail.com>},