Logging outgoing emails in Rails 3

by Trevor Turk

Let’s say you want to have a log of all outgoing emails in your Rails 3 app. Thanks to some pretty sweet notification support in the Mail gem, it’s really simple. Here’s an example using Mongoid:

Initially, I was logging the entire contents of the email, but that included attachments as well. So, now I’m just logging the body. I wonder if there’s a better choice of what to log, though…

Any ideas?

Advertisement