Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A web interface for browsing Ruby on Rails sent emails
Ruby JavaScript

README.md

letter_opener_web

Build Status Gem Version Code Climate Gittip Gitter chat

Gives letter_opener an interface for browsing sent emails.

Check out http://letter-opener-web.herokuapp.com to see it in action.

Installation

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

gem 'letter_opener_web', '~> 1.2.0', :group => :development

Usage

Add to your routes.rb:

Your::Application.routes.draw do
  if Rails.env.development?
    mount LetterOpenerWeb::Engine, at: "/letter_opener"
  end
end

And make sure you have :letter_opener delivery method configured for your app. Then visit http://localhost:3000/letter_opener after sending an email and have fun.

If you are running the app from a Vagrant machine, you might want to skip letter_opener's launchy calls and avoid messages like these:

12:33:42 web.1  | Failure in opening /vagrant/tmp/letter_opener/1358825621_ba83a22/rich.html
with options {}: Unable to find a browser command. If this is unexpected, Please rerun with
environment variable LAUNCHY_DEBUG=true or the '-d' commandline option and file a bug at
https://github.com/copiousfreetime/launchy/issues/new

In that case (or if you just want to browse mails using the web interface), you can set :letter_opener_web as your delivery method on your config/environments/development.rb:

config.action_mailer.delivery_method = :letter_opener_web

# If not everyone on the team is using vagrant
config.action_mailer.delivery_method = ENV['USER'] == 'vagrant' ? :letter_opener_web : :letter_opener

Usage on Heroku

Some people use this gem on staging environments on Heroku and to set that up is just a matter of moving the gem out of the development group and enabling the route for all environments on your routes.rb.

In order words, your Gemfile will have:

gem 'letter_opener_web', '~> 1.2.0'

And your routes.rb:

Your::Application.routes.draw do
  mount LetterOpenerWeb::Engine, at: "/letter_opener"
end

You might also want to have a look at the sources for the demo available at https://github.com/fgrehm/letter_opener_web_demo.

NOTICE: Using this gem on Heroku will only work if your app has just one Dyno and does not send emails from background jobs. For updates on this matter please subscribe to GH-35

Acknowledgements

Special thanks to @alexrothenberg for some ideas on this pull request.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.