Open-source project
ryanb/letter_opener avatar
ryanb/letter_opener

letter_opener writes your sent mail to a directory under tmp

Preview mail in the browser instead of sending.

3,836 stars245 forksRubyMIT

At a glance

What is it?
A Ruby gem that previews development mail in the browser instead of sending it, where the stated point is not sending a test email to a real address, the messages are written out as files into a directory inside the application, and browser launching is delegated to Launchy, which may need different handling in a headless or container environment.
Who is it for?
letter_opener is the right default for development mail in a Rails or Ruby application, because configured Action Mailer deliveries are previewed locally instead of sent through a mail server. Verify every relevant environment and delivery path rather than assuming unrelated mailers are intercepted.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Activity is slowing. The repository last received commits 6 months ago.
What is it written in?
Mainly Ruby, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • ryanb/letter_opener3,836 ★ · -3
Star history
Repository2026-09-242026-11-15
ryanb/letter_opener3.8k3.8k

-3 Stars in the last 52 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The gem exists so a test email never reaches a real person

The stated reasons are convenience and safety, and the second one is the point. Without it you do not have to set up email delivery in a development environment, and you no longer have to worry about accidentally sending a test email to someone else's address. The setup reflects that intent: the gem goes in the development group.

rb
gem "letter_opener", group: :development

Then two lines in the development environment file, one setting the delivery method and one setting the flag that actually performs deliveries.

rb
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.perform_deliveries = true

Both are needed. That is the whole Rails integration, and it is scoped to one environment file, which is the correct place for it.

Your sent mail becomes files in a directory inside the application

The messages are not held in memory and not shown in a running view. The page says they are stored in a directory under tmp, and the configuration block lets you move that directory.

rb
config.location = Rails.root.join('tmp', 'my_mails')

So every development email your application sends becomes a file on disk, inside the application tree, at a predictable path. That is the mechanism, and it is what makes the gem work without a browser being useful. What the page does not say is anything about what those files contain. They are the rendered message, so a password reset or an invitation email that carries a token leaves that token sitting in a directory that is normally ignored by version control and served by nothing. It is a development-only tool and the directory is a temporary one, but anyone reading the page for the first time is not told that.

Four routes for attaching the same delivery method

Four ways to wire this up are given, and they differ in how much ceremony they need. In Rails, two configuration lines in an environment file. With the Mail gem directly, a defaults block that names the delivery method and passes a location.

rb
Mail.defaults do
  delivery_method LetterOpener::DeliveryMethod, location: File.expand_path('../tmp/letter_opener', __FILE__)
end

With the Pony gem, an options hash using a differently named key for the same idea. And with ActionMailer used on its own without Rails, a call that registers the delivery method on the base class and then sets it as the default. Four code paths for one feature, which is generous coverage for a gem whose whole job is one class, and it does mean the integration you need depends on which mailer you already have.

The browser launch is delegated, and containers break it in a documented way

Opening the mail is not this gem's job. It uses a separate library for that, and the page is clear about the assumption involved: the Ruby process has to be running on your local development machine, and if you are on a separate staging server or a virtual machine this will not work. Two remote alternatives are named, a hosted service and a self-hosted catcher.

For containers the page goes further and gives the exact warning you will see, which is a browser command not found error naming an environment variable and a debug flag.

code
WARN: Launchy::CommandNotFoundError: Unable to find a browser command.

And the two lines that fix it.

code
LAUNCHY_DRY_RUN=true
BROWSER=/dev/null

Setting the dry run is the interesting half, because it tells the launcher not to launch anything. That is the correct behaviour where no browser exists, and documenting it as two variables rather than a code change is the sort of thing that saves an afternoon.

The default view of your mail includes metadata

There is a rendering option with two values, and the default is the louder one.

rb
config.message_template = :light

The page describes the light value as rendering only the message body, with no metadata, no extra containers and no styling, and describes the default as rendering a styled message that shows useful metadata. So out of the box you get a page with your headers and routing information visible above the body, which is what you want while debugging a mailer and is not what you want if you are checking how the body looks. The configuration comment also misspells override, which is the sort of thing that survives because the block gets copied rather than read.

Configuring the file URI scheme

The configuration block covers the message location, rendering template and file URI scheme. The README includes a `config.file_uri_scheme` example for WSL; its distribution name and path must match the user's own environment. Check the current README when setting it, and test that the resulting file URL opens on the host.

The maintainer names the successor instead of building it

There is a note about what this project deliberately is not. In order to keep the project simple, the author says, there are no plans to turn it into a Rails engine with an interface for browsing the sent mail, and points instead at a separate gem that does that, by a different author. The same pattern runs through the rest of the page: browser launching is delegated to another library, and two hosted or self-hosted services are named for the remote case rather than reimplemented. Nothing here is a criticism of the scope. It is a coherent division of labour for a gem whose hardest problem is being safe, and it does mean a team that wants to browse its mail has to take on a second project.

Pinning the gem and maintaining the project

The absence of GitHub releases does not prevent version pinning: RubyGems lists versioned releases, including 1.10.0. Choose an appropriate version constraint in the Gemfile and retain `Gemfile.lock` to reproduce the resolved dependencies. The last commit to the default branch is dated 2026-04-25. Development is the conventional Ruby pair: a gemspec, a Rakefile, a spec directory and an RSpec configuration, with the contribution instructions being to fork, run bundle and run rake. Four external projects are credited and all four are load bearing or adjacent: the mail library that inspired it and supplied its template, the browser launcher the whole remote case depends on, the web interface gem the author points at instead of building, and the named person who helps maintain it.

Editorial conclusion

letter_opener is the right default for development mail in a Rails or Ruby application, because configured Action Mailer deliveries are previewed locally instead of sent through a mail server. Verify every relevant environment and delivery path rather than assuming unrelated mailers are intercepted. Two things to know. What it writes to disk is the full rendered message, so any credential a notification carries ends up as a file in a directory inside the application, and the page does not warn about that. In a headless container the documented Launchy settings suppress the browser launch; use an accessible mail preview interface or inspect the stored files to read messages.

Frequently asked questions

What is a letter opener called?

That is a question about a kitchen tool. This repository is a Ruby gem that previews mail in the default browser instead of sending it, and it is meant to be used in development.

how to use letter opener

Add the gem to your development group, install it with bundle, and set the mailer's delivery method in your development environment file. Messages are then written to a directory under tmp instead of being sent, and they open in your default browser.

how to properly use letter opener

Set it on the development group only and point the mailer's delivery method at it in the development environment file. Both the delivery method and the flag that performs deliveries need setting. The storage directory defaults to one under tmp and can be moved in the configuration block.

What is letter opener app on mac?

The gem opens your mail using a browser launcher library that picks the platform's default browser. You can choose which application opens the mail through an environment variable or by setting the launcher's application attribute in an initializer.

Does letter opener work in a Docker container?

Not without a change. The page says the browser launch assumes the Ruby process is on your local machine and will not work on a separate staging server or virtual machine. For containers it gives two environment variables that disable the launch, and names a hosted service and a self-hosted catcher as the remote alternatives.

Which letter opener is the best?

The page compares no letter openers of any kind. It documents one gem, three configuration options and the four ways to attach its delivery method to the mail libraries it supports.

Official sources

  1. Issues
  2. License: MIT
  3. README
  4. ryanb/letter_opener on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/ryanb-letter-opener.svg)](https://hysenlabs.com/projects/ryanb-letter-opener)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/ryanb-letter-opener.svg)](https://hysenlabs.com/projects/ryanb-letter-opener)

Was this useful?