Redirect all mails while developing your rails app
Ever had a “oh-sh*t” moment when doing something related to mailing in development mode? This little plugin for rails prevents you from having any more of those moments, in a very clever way.
The plugin is called MailBouncer, and is written by a colleague of mine, Trym Skaar. The installation is as easy as
config.gem "trym-mail_bouncer", :lib => "mail_bouncer", :source => "http://gems.github.com" |
in your environment.rb, or you can still do
gem install trym-mail_bouncer --source http://gems.github.com |
After installing, go into $RAILS_ROOT/config/initializers/mail_bouncer.rb and do your setup
1 2 3 4 |
MailBouncer.configure do |config| config.enabled = %w(development test).include? ENV["RAILS_ENV"] config.recipients = 'your@email.com' end |
And you’re done. All mails sent while being in development- or test-mode on your project will be redirected to your own debug mail account instead of out to your customers, and it will keep all headers intact so you can use it for debugging.
It has saved my day a couple of times already :-)
Write a comment