Preview mail in the browser instead of sending.
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 162 commits behind ryanb:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Letter Opener

Preview email in the browser instead of sending it. This means you do not need to set up email delivery in your development environment, and you no longer need to worry about accidentally sending a test email to someone else's address.

Rails Setup

First add the gem to your development environment and run the bundle command to install it.

gem "letter_opener", :group => :development

Then set the delivery method in config/environments/development.rb

config.action_mailer.delivery_method = :letter_opener

Now any email will pop up in your browser instead of being sent. The messages are stored in tmp/letter_opener.

Non Rails Setup

If you aren't using Rails, this can be easily set up with the Mail gem. Just set the delivery method when configuring Mail and specify a location.

require "letter_opener"
Mail.defaults do
  delivery_method LetterOpener::DeliveryMethod, :location => File.expand_path('../tmp/letter_opener', __FILE__)

Alternatively, if you are using ActionMailer directly (without Rails) you will need to add the delivery method.

require "letter_opener"
ActionMailer::Base.add_delivery_method :letter_opener, LetterOpener::DeliveryMethod, :location => File.expand_path('../tmp/letter_opener', __FILE__)
ActionMailer::Base.delivery_method = :letter_opener

Development & Feedback

Questions or problems? Please use the issue tracker. If you would like to contribute to this project, fork this repository and run bundle and rake to run the tests. Pull requests appreciated.

Special thanks to the mail_view gem for inspiring this project and for their mail template. Also thanks to Vasiliy Ermolovich for helping manage this project.