Rails comes with a useful library for generating emails called ActionMailer. ActionMailer has three delivery modes test, sendmail, and SMTP.

SMTP is what, by and large, everybody uses in production but who wants to setup a local SMTP server for development work? I mean you don't really want send the mail, just to know it would have been delivered. Even thinking about sendmail makes me shudder and the test delivery method just sticks the things in an array that you then need to deal with. That's fine in a test case but you don't want code for that in your app.

So what do you do? Well yesterday I mocked up the simplest, dumbest, Ruby SMTP server you can imagine. It's called Mailtrap and that's exactly what it does. It speaks just enough SMTP to allow ActionMailer to make a connection and send it a message. Mailtrap writes the message into a file for you (and you can tail -f the file if you're interested in seeing it).

Mailtrap has, essentially, zero configuration. By default it creates an SMTP server on localhost port 2525 that writes messages into /var/tmp/mailtrap.log. If you're happy with the default you can be up and running with:

sudo gem install -y mailtrap
mailtrap start

then just configure your ActionMailer for development (using RAILS_ROOT/config/environment/development.rb) settings as: