Letter opener – immediate mail delivery in development

Ruby on Rails / ActionMailer

Emails are very important part of almost every Ruby on Rails application so it’s important to test them well during the development process. Setting up a local mail server may be a little problematic and time-consuming process but there is another way to test our emails immediately. There is a letter opener gem which would handle emails for you and open them in your browser each time you will send them to your app.


We have to add it to our Gemfile and then run bundle install:

gem "letter_opener", :group => :development

We want this gem to be available only in the development environment so we have to specify a group to which this gem belongs. If you already have development group defined then just add this gem to it.


We have our gem installed but now we have to let know Rails that we want to use it for the emails delivery. In order to do this, open config/environments/development.rb file and add the following line:

config.action_mailer.delivery_method = :letter_opener

And that’s it! Try now to trigger one of your emails by using your app or simply from console level. What is nice you can preview both HTML and plain versions of your e-mail. Each opened email would be saved in tmp directory so you can easily clear it anytime you want.

If you want to use this gem without rails or you want to check more advanced configuration, visit gem homepage on GitHub