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.
- 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
Add gem to development group:
group :development do
gem "rails-mailer-sandbox"
endSet it up:
bundle install
bundle exec rake rails_mailer_sandbox:setupRestart 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.
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 = trueMount inbox in config/routes.rb:
mount RailsMailerSandbox::Server.new => "/rails_mailer_sandbox" if Rails.env.development?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.
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.gemspecCI 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. 📝
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.
MIT. Build useful things and test your emails. 🎉