Skip to content


Repository files navigation


License: MIT Gem Version MailPace Rails

MailPace lets you send transactional emails from your app over an easy to use API.

The MailPace Rails Gem is a plug in for ActionMailer to send emails via MailPace to make sending emails from Rails apps super simple.

New in 0.3.0: The ability to consume inbound emails from MailPace via ActionMailbox


Once installed and configured, continue to send emails using ActionMailer and receive emails with ActionMailbox like normal.

Other Requirements

You will need an MailPace account with a verified domain and organization with an active plan.


Account Setup

Set up an account at MailPace and complete the Onboarding steps

Gem Installation

Add this line to your application's Gemfile:

gem 'mailpace-rails'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mailpace-rails

Configure the Gem

First you will need to retrieve your API token for your sending domain from MailPace. You can find it under Organization -> Domain -> API Tokens.

Use the encrypted secret management to save your API Token to config/credentials.yml.enc by running the following:

rails secret
rails credentials:edit

Then add your token:

mailpace_api_token: "TOKEN_GOES_HERE"

Set MailPace as your mail delivery method in config/application.rb:

config.action_mailer.delivery_method = :mailpace
config.action_mailer.mailpace_settings = { api_token: Rails.application.credentials.mailpace_api_token }


You can tag messages and filter them later in the MailPace UI. To do this, pass the tags as a header by adding a tag variable to your mail method call.

class TestMailer < ApplicationMailer
  default from: '',
          to: ''

  def single_tag
      tags: 'test tag' # One tag

  def multi_tag
      tags: "['test tag', 'another-tag']" # Multiple tags

Note that this should always be a string, even if using an array of multiple tags.


To add a List-Unsubscribe header, pass a list_unsubscribe string to the mail function:

class TestMailer < ApplicationMailer
  default from: '',
          to: ''

  def list_unsub_header
      list_unsubscribe: ''

ActionMailbox (for receiving inbound emails)

As of v0.3.0, this Gem supports handling Inbound Emails (see for more details) via ActionMailbox. To set this up:

  1. Tell Action Mailbox to accept emails from MailPace in config/environments/production.rb
config.action_mailbox.ingress = :mailpace
  1. Generate a strong password that Action Mailbox can use to authenticate requests to the MailPace ingress. Use bin/rails credentials:edit to add the password to your application's encrypted credentials under action_mailbox.ingress_password, where Action Mailbox will automatically find it:
  ingress_password: ...

Alternatively, provide the password in the RAILS_INBOUND_EMAIL_PASSWORD environment variable.

  1. Configure MailPace to forward inbound emails to /rails/action_mailbox/mailpace/inbound_emails with the username actionmailbox and the password you previously generated. If your application lived at you would configure your MailPace inbound endpoint URL with the following fully-qualified URL:

That's it! Emails should start flowing into your app just like magic.


For support please check the MailPace Documentation or contact us at


Please ensure to add a test for any change you make. To run the tests:


Pull requests always welcome


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