我正在尝试让 exception_notification 和 rails 一起工作。我查看了许多其他问题,并在exception_notification gem页面上大量阅读了自述文件。但是,在主要版本切换到 4.0 之前,大多数其他教程和问题似乎都已经过时了一年左右。更奇怪的是,在开发模式下似乎会发送正确的电子邮件,但不是在生产模式下,这是我真正想要的。
以下是相关代码:
我gem 'exception_notification'
按照自述文件中的说明安装了。
然后...在 config/environments/production.rb
Whatever::Application.configure do
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => 'blah@blah.com',
:password => 'blahblah',
:authentication => 'plain',
:enable_starttls_auto => true
}
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = {
:host => 'www.blah.com'
}
ActionMailer::Base.default :from => 'BlahApp <reply@blah.com>'
Paperclip.options[:command_path] = "/usr/bin/"
config.middleware.use ExceptionNotification::Rack,
:email => {
:email_prefix => "[Error!] ",
:sender_address => %{<reply@blah.com>},
:exception_recipients => ['"Test Recipient" <tester@blah.com>', '"Test 2" <test2@gmail.com>'],
}
正如我所说,当我将它复制/粘贴到 development.rb 中时,它似乎可以正常工作并发送电子邮件(虽然我实际上并没有收到它们,但 Paperclip 正在捕捉它们并在浏览器中打开它们,它们有什么我想要他们)。然后在生产中,什么都没有发生,当我检查日志文件时,它似乎甚至没有尝试发送电子邮件。没有收到任何错误,除了我故意抛出的错误。
我看到有一些与 SMTP 相关的问题,所以我也尝试直接将 smtp_settings 直接放入 ExceptionNotification 的电子邮件配置哈希中(同时在外部仍然具有相同的设置),但没有运气。
我觉得我错过了一些愚蠢的东西。它应该非常简单易用。有什么想法吗?非常感谢!