【问题标题】:Exception Notifier in Rails 4 app's not sending emailRails 4 应用程序中的异常通知程序不发送电子邮件
【发布时间】:2014-12-07 05:13:46
【问题描述】:

我整个下午都在与这个问题作斗争。

我用过这个宝石:

gem 'exception_notification'

然后我把它放到/config/environments/production.rb 文件中:

config.action_mailer.default_url_options = { :host => 'http://www.website.com' }

  config.action_mailer.delivery_method = :sendmail
  # Defaults to:
  # config.action_mailer.sendmail_settings = {
  #   location: '/usr/sbin/sendmail',
  #   arguments: '-i -t'
  # }
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  #config.action_mailer.default_options = {from: 'admin@website.com'}
  config.action_mailer.delivery_method = :smtp

  config.action_mailer.smtp_settings = {
    :address => "smtp.gmail.com",
    :port => 587,
    :domain => "gmail.com",
    :user_name => "myemail@gmail.com",
    :password => "password",
    :authentication => "plain",
    :enable_starttls_auto => true
  }

  config.middleware.use ExceptionNotification::Rack,
    :email => {
      :email_prefix => "[App Error] ",
      :sender_address => %{"notifier" <myemail@gmail.com>},
      :exception_recipients => %w{error_email@gmail.com}
    }

但没有成功。

所以我试着把它放到/config/application.rb 文件中:

...
module MyApp
  class Application < Rails::Application
    ...
    config.middleware.use ExceptionNotification::Rack,
      :email => {
        :email_prefix => "[App Error] ",
        :sender_address => %{"notifier" <myemail@gmail.com>},
        :exception_recipients => %w{error_email@gmail.com}
      }
  end
end

我如何测试它 - 我将 URL 放入不存在的 ID,例如 /users/1000000。但我的收件箱没有收到任何包含此错误的电子邮件。

谁能帮我解决这个问题?

谢谢你们。

【问题讨论】:

  • 你有解决办法吗?

标签: ruby-on-rails ruby exception-handling actionmailer exception-notification


【解决方案1】:

我知道这是一篇旧帖子,但我可能会有答案。您的生产配置中有两个 action_mailer 配置:

config.action_mailer.delivery_method = :sendmail
# and also...
config.action_mailer.delivery_method = :smtp

可能想要删除其中一个。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-25
    • 2014-10-01
    • 2015-04-27
    • 1970-01-01
    • 2017-10-06
    • 2013-04-28
    相关资源
    最近更新 更多