ruby-on-rails – Rails 4异常通知程序不会在开发模式下发送电子邮件

我试图在本地测试Exception Notifier(开发).这是我目前的设置:

development.rb

Myapp::Application.configure do
  # Set Mailer default url
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.default_url_options = { :host => '0.0.0.0:3000' }
  #config.action_mailer.delivery_method = :file
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
       :address              => 'smtp.gmail.com',
       :port                 => 587,
       :domain               => 'gmail.com',
       :user_name            => 'username@gmail.com',
       :password             => 'password',
       :authentication       => 'plain',
       :enable_starttls_auto => true
   }

  config.middleware.use ExceptionNotification::Rack,
    :email => {
      :email_prefix => "[Myapp Error] ",
      :sender_address => %{"notifier" <no-reply@myapp.com>},
      :exception_recipients => %w{myemail@gmail.com}
    }
end

但是当我在应用程序中“创建”错误时 – 例如,如果我设置了不存在的ID,例如

http://localhost:3000/users/12270/edit

我在浏览器中只看到错误,但电子邮件未发送(电子邮件凭据正确).

我错过了什么?

比你

最佳答案 要在开发模式下禁用错误页面,您还需要设置:

config.consider_all_requests_local = false
点赞