rack-mail-exceptions-notification-middleware

gmarik 1 min

I’m working on my small project devz.info - a sinatra powered app. And by nature I wanted to have exceptions delivered to my mailbox same way as exception_notification rails plugin does.

But mailexceptions middleware for rack didn’t really work for TLS enabled smtp, so I contributed patch and it has been applied!

Here’s sample config.ru

require 'rack'
require 'rack/contrib'

use  Rack::MailExceptions.new do |mail|
  mail.to '[email protected]'
  mail.from '[email protected]'
  mail.subject '[ERROR] %s'
  mail.smtp { :server         => 'smtp.gmail.com',
              :domain         => 'gmail.com',
              :port           => 587,
              :authentication => 'plain',
              :user_name      => 'your_user',
              :password       => 'your_pass'}
end

run lambda {|env| raise 'whoops' }

see tests for more.

Read More
Blogging with Jekyll, Rack and Heroku for free!
Native Irb experience on OSX
Comments
read or add one↓