Sunabamail

Sunabamail is an Action Mailer delivery method that stores emails in the database - so you can inspect them from anywhere via a built-in web UI.

Why Sunabamail?

In modern Rails applications, emails are often generated across multiple processes — web servers, background workers, and staging environments.

Sunabamail is designed for this kind of setup. In other words, it makes emails observable regardless of where they are generated.

By storing emails in the database, it allows you to:

  • Access emails from any process or server
  • Inspect emails generated by background jobs
  • Verify email behavior safely in staging

It works well alongside traditional development tools, while focusing on setups where emails need to be observable across processes and environments.

Features

  • Drop-in replacement for ActionMailer delivery method
  • Stores emails in a dedicated database (separate from your app data)
  • Built-in Rails Engine UI (/sunabamail) for browsing emails
  • Works across processes and servers
  • Ideal for development and staging

Installation

bundle add sunabamail --group development
bin/rails sunabamail:install

This will:

  • Configure action_mailer.delivery_method
  • Mount the engine
  • Generate db/sunabamail_schema.rb

Database configuration

Add a dedicated database for Sunabamail.

SQLite

development:
  primary:
    <<: *default
    database: storage/development.sqlite3
  sunabamail:
    <<: *default
    database: storage/development_sunabamail.sqlite3
    migrations_paths: db/sunabamail_migrate

MySQL / PostgreSQL / Trilogy

development:
  primary: &primary_development
    <<: *default
    database: app_development
    username: app
    password: <%= ENV["APP_DATABASE_PASSWORD"] %>
  sunabamail:
    <<: *primary_development
    database: app_development_sunabamail
    migrations_paths: db/sunabamail_migrate

Then run:

bin/rails db:prepare

Usage

Start your Rails server and visit:

http://localhost:3000/sunabamail

You will see a list of captured emails and their contents:

Web interface

You can:

  • Browse captured emails
  • Inspect subject, body, and headers
  • Debug mailer behavior without sending real emails

Usage in staging

Sunabamail can also be used in staging environments.

This is especially useful when:

  • You want to verify email behavior without sending real emails
  • Your app runs background jobs on separate workers

NOTE Not intended for production use.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/hamajyotan/sunabamail.

License

The gem is available as open source under the terms of the MIT License.