6

I am migrating from rails 2.3 to rails 3.1, I am trying to send a email when exception is generated. I am using exception_notification gem.

My rest of the emails are working. But exception mail is not getting fired.

below are the settings in my staging.rb file.

config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true

and following is the code in application.rb

C::Application.config.middleware.use ExceptionNotification::Rack,
  :email => {
    :email_prefix => "[#{Rails.env.to_s.upcase} Error] ",
    :sender_address => %{"Exception Notifier " <email_id>},
    :exception_recipients => %w{email_id}
  }

I am not sure why the email is not triggering, nor do i see any error. Any help would be appriciated, Thanks.

opensource-developer
  • 2,826
  • 4
  • 38
  • 88

2 Answers2

4

You need to configure your app like this:

C::Application.config.middleware.use ExceptionNotification::Rack,
  :email_prefix => "[#{Rails.env.to_s.upcase} Error] ",
  :sender_address => %{"Exception Notifier " <email_id>},
  :exception_recipients => %w{email_id}

Note You have excesive :email => {...} declaration which is used in configuration for exception_notifier version 4 (see here). But you can't use version 4 of exception_notifier with rails 3.1.

I created a repository at github https://github.com/dimakura/stackoverflow-projects/tree/master/32118817-exception-notification, which is a working example. I used ruby 1.9.3, rails 3.1.12 and exception_notifier 3.0.1. I guess you are using the same gems or close to it.

Note 2 When I added email: {...} to the configuration, exception messages stop to arrive.

dimakura
  • 7,575
  • 17
  • 36
1

move the gem configuration code to the environment.rb file, instead of application.rb