Exception Notifier Plugin Fix for Rails 2.2.2+

For those of us who are still using the Exception Notifier Plugin, be careful when upgrading to a recent version of Rails. Doing so with Rails 2.2.2+ and the configuration is in an environment file (#{RAILS_ROOT}/config/environments/production.rb for instance) will not send notification emails. Instead, it'll fail with:

Net::SMTPSyntaxError (501 5.1.3 Bad recipient address syntax ): /opt/ruby-enterprise-1.8.6-20090113/lib/ruby/1.8/net/smtp.rb:679:in `check_response' /opt/ruby-enterprise-1.8.6-20090113/lib/ruby/1.8/net/smtp.rb:652:in `getok' /opt/ruby-enterprise-1.8.6-20090113/lib/ruby/1.8/net/smtp.rb:634:in `rcptto' /opt/ruby-enterprise-1.8.6-20090113/lib/ruby/1.8/net/smtp.rb:545:in `send0' /opt/ruby-enterprise-1.8.6-20090113/lib/ruby/1.8/net/smtp.rb:544:in `each' /opt/ruby-enterprise-1.8.6-20090113/lib/ruby/1.8/net/smtp.rb:544:in `send0' /opt/ruby-enterprise-1.8.6-20090113/lib/ruby/1.8/net/smtp.rb:471:in `sendmail' /opt/ruby-enterprise-1.8.6-20090113/lib/ruby/1.8/net/smtp.rb:378:in `start'

Several ways to work around this problem. You could wrap the configuration inside an after_initialize block:

config.after_initialize do ExceptionNotifier.exception_recipients = %w(joe@schmoe.com bill@schmoe.com) ExceptionNotifier.sender_address = %("App Error" ) ExceptionNotifier.email_prefix = "[APP] " end

The other solution is to put the configuration in an initializer file.

Of course, there is the option to instead use Hoptoad or Exceptional.

There is a lighthouse ticket if you want to follow the discussion.

Ruby on Rails. March 23, 2009 - 07:45PM. 0 Comments