I have some pretty large changes and docs planned but right now it
should be useable with:
require 'rack/contrib'
use Rack::MailExceptions do |mail|
mail.to 'f...@example.com'
mail.subject '[ERROR] %s'
end
run lambda { |env| fail 'boom!' }
Assuming you have an SMTP server running on localhost:25, this should
just work. Some additional notes:
* You can specify a "mail.from" address.
* The '%s' in the subject is replaced with the exception's message.
* Configure SMTP settings with: mail.smtp :server => '...', :user_name
=> '', :password => '...', etc. See
http://github.com/rack/rack-contrib/blob/master/lib/rack/contrib/mailexceptions.rb#L19
for a list of options.
* Only SMTP is currently supported. I plan to support using a local
mail(1) command at some point in the future.
* The MailExceptions middleware only works when exceptions are raised
up through the middleware chain. If your framework/app rescues
exceptions and turns them into error pages, you'll need to find a way
to disable that.
* All exceptions are re-raised after the mail is sent. Put
Rack::ShowExceptions (or something like it) before MailExceptions in
the middleware chain to get error pages.
Thanks,
Ryan