People care about emails. They don’t like to be bothered with emails they find unimportant, especially not if they are sent by mistake, have the wrong content or looks weird.

Many of the applications we build send out a lot of emails, and for some, it is a critical part of the system. Lokalebasen is such an application, and the people behind wanted to monitor all outgoing mail, whether generated by a page request, a cron job, an administrator or anything else.

I built a clever little monkey-patch for the Ruby on Rails ActionMailer that makes sure that all outgoing emails has a certain email address put on BCC. This is not visible to the recipient, but it allows you to keep an archive of all outgoing mail, which is certainly useful – especially for support and bug-tracking.

Drop this into your lib-folder (remember to change the email address):

- and be sure to enable it by adding this line to environment/production.rb (you probably don’t want to BCC mails sent in development and test mode):

ActionMailer::Base.send(:include, BccAllMails)

Bookmark and Share