The project is in a healthy, maintained state
Intercepts ActionMailer emails in development and provides mountable Web UI to preview them.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 3.0

Runtime

~> 0.2
~> 2.8
>= 2.0
 Project Readme

Rails Mailer Sandbox ๐Ÿ“ฌ

CI Gem Version Documentation License: MIT

Catch Rails emails locally before they escape into the wild. Rails Mailer Sandbox stores real .eml messages and gives you a Mailtrap-inspired inbox right inside your Rails app. No SMTP server, database, account, or monthly bill needed.

โœจ What You Get

  • Persistent MIME messages across Rails restarts
  • Search by subject, sender, recipient, or full body
  • HTML, plain-text, and raw-source views
  • Desktop, tablet, and mobile preview widths
  • From, To, Cc, Bcc, date, and message-size details
  • Inline cid: image previews and attachment downloads
  • UTF-8 attachment filenames
  • Automatic inbox refresh without repeatedly parsing every email
  • Individual and bulk deletion
  • Sandboxed HTML previews with scripts and remote resources blocked
  • Filesystem locking and atomic writes for Rails and background workers

๐Ÿš€ Get Started

Add gem to development group:

group :development do
  gem "rails-mailer-sandbox"
end

Set it up:

bundle install
bundle exec rake rails_mailer_sandbox:setup

Restart Rails, send any Action Mailer email, then visit:

๐Ÿ‘‰ http://localhost:3000/rails_mailer_sandbox

Setup creates config/initializers/rails_mailer_sandbox.rb, configures Action Mailer, and mounts Web UI. Run task again safely; it will not overwrite edited initializer.

๐Ÿ”ง Manual Setup

Prefer doing it yourself? Add this to config/environments/development.rb:

config.action_mailer.delivery_method = :rails_mailer_sandbox
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true

Mount inbox in config/routes.rb:

mount RailsMailerSandbox::Server.new => "/rails_mailer_sandbox" if Rails.env.development?

๐Ÿ’พ Where Emails Live

Default path: Rails.root/tmp/rails_mailer_sandbox.

Want another location? Set it in initializer:

RailsMailerSandbox.storage_path = Rails.root.join("storage", "development_mail")

Keep custom storage out of version control. bin/rails tmp:clear removes default inbox. Filesystem storage targets local development on one host, not distributed deployments or giant email archives.

๐Ÿงช Development

git clone https://github.com/azmi2409/rails-mailer-sandbox.git
cd rails-mailer-sandbox
bundle install
bundle exec ruby -Ilib test/rails_mailer_sandbox_test.rb
gem build rails-mailer-sandbox.gemspec

CI runs tests and gem build on Ruby 3.0, 3.1, 3.2, and 3.3. Found a bug or have a neat focused improvement? Read CONTRIBUTING.md, then open an issue or pull request. ๐Ÿ™Œ

Release notes live in CHANGELOG.md. ๐Ÿ“

๐Ÿ”’ One Important Rule

Use this gem in development only. Captured emails may contain reset links, personal data, or other secrets. Never expose mounted inbox publicly or enable it in production.

๐Ÿ“„ License

MIT. Build useful things and test your emails. ๐ŸŽ‰