Mailtrap by Railsware

This add-on is operated by Railsware

Safe email delivery testing for your staging app

Mailtrap by Railsware

Last Updated: 19 March 2014

Table of Contents

Mailtrap is an add-on for providing safe email delivery testing.

Mailtrap is a dummy SMTP server for development teams to test, view, share transactional and other emails sent from DEVELOPMENT and STAGING environments, without spamming real customers

mock SMTP server

Provisioning the add-on

Mailtrap can be attached to a Heroku application via the CLI:

$ heroku addons:add mailtrap
-----> Adding mailtrap to sharp-mountain-4005... done, v18 (free)

MAILTRAP_HOST, MAILTRAP_PORT, MAILTRAP_USER_NAME, MAILTRAP_PASSWORD settings will be available in the app configuration and will contain the credentionals used to access the newly provisioned Mailtrap service instance. This can be confirmed using the heroku config command.

$ heroku config -s | grep MAILTRAP

After installing Mailtrap the application should be configured to fully integrate with the add-on.

Local setup

After provisioning the add-on it’s necessary to locally replicate the config vars so your development environment can operate against the service.

Though less portable it’s also possible to set local environment variables using the export command locally.

Use Foreman to configure, run and manage process types specified in your app’s Procfile. Foreman reads configuration variables from an .env file. Use the following command to add the MAILTRAP values retrieved from heroku config to .env.

$ heroku config -s | grep MAILTRAP >> .env
$ more .env

Credentials and other sensitive configuration values should not be committed to source-control. In Git exclude the .env file with: echo .env >> .gitignore.

Using with Rails 3.x

In config/environments/*.rb specify ActionMailer defaults:

if ENV['MAILTRAP_HOST'].present?
  ActionMailer::Base.delivery_method = :smtp
  ActionMailer::Base.smtp_settings = {
    :user_name => ENV['MAILTRAP_USER_NAME'],
    :password => ENV['MAILTRAP_PASSWORD'],
    :address => ENV['MAILTRAP_HOST'],
    :port => ENV['MAILTRAP_PORT'],
    :authentication => :plain

Using with Python/Django

Add the following to



The dashboard can be accessed via the CLI:

$ heroku addons:open mailtrap
Opening mailtrap for sharp-mountain-4005…

or by visiting the Heroku apps web interface and selecting the application in question. Select Mailtrap from the Add-ons menu.

dummy SMTP server. Mailtrap Heroku add-on.

Removing the add-on

Mailtrap can be removed via the CLI.

This will not destroy associated data and can be undone!

$ heroku addons:remove mailtrap
-----> Removing mailtrap from sharp-mountain-4005... done, v20 (free)


All Mailtrap support and runtime issues should be submitted via on of the Heroku Support channels. Any non-support related issues or product feedback is welcome at