Forwarding Inbound Email with Heroku

What’s This? Forwarding Inbound Email?

We have been asked in our community Slack channel about forwarding inbound email messages via SparkPost to a mailbox. Our product folks are looking into adding it to our roadmap as a first-class feature of SparkPost, but in the meantime, I’ve put together a sample app that uses Heroku to provide similar functionality using today’s API endpoints.

The code can be found in GitHub, in the SparkPost/sp-forwarding-service repository.

Heroku has a great feature called the “Deploy to Heroku” button. This makes it super easy to get set up with the Forwarding Service. Either head on over to the repository’s README or just click here:

Let’s Deploy the Service!

After you’ve hit the big purple button you’ll see a Heroku sign-up screen. If you’re a new user, sign up! If you’re already a Heroku user, just click the “Log In” link at the bottom of the page.

Once you’ve signed up or logged in, you’ll get to a simple configuration page. Here you can add a name for the application. That is optional—if you leave it blank, Heroku will invent some funky name for you like  mesmerizing-badger-54321.

There is a choice of which region to run the app in. Just choose United States here, as that’s where SparkPost’s servers are!

Now comes a couple of important “config vars” to set up. First the FORWARD_FROM, which will be the email address the recipient will see as the sender of the message. The default value uses the sandbox domain that is limited to 50 messages for the lifetime of your account, so change this for anything but a demo. The domain used here must be verified from the SparkPost UI before you can begin to use the app.

Next comes FORWARD_TO. Set this to the address of the mailbox where you want to receive your forwarded messages.

Now you can hit the “Deploy for Free” button to activate the code from GitHub.

How Do I Choose Which Mails Get Forwarded?

That’s a great question. You might think we’re done with configuring this thing, but no, there is one more step.

At the bottom of the page you will see “Your app was successfully deployed.” Hit the button marked “View” just under this to be taken to the app’s setup page.

Here you will see that the page is checking for an inbound (“relay”) webhook. Of course it won’t find one, because you’ve not set it up yet. Hang on; we’ll get to that.

Before you create that webhook, you’ll need a domain name that has been set up in DNS to have MX records pointing to SparkPost. Specifically, you’ll need to add the following three MX records for your domain:


Once these records have been added to your domain, you can go back to the app’s set up page. Type your domain name into the appropriate box and hit “Add domain.” This tells the app to create both an inbound domain and a relay webhook in SparkPost.

That’s it! Messages sent to any mailbox @ your inbound domain will be directed to SparkPost. SparkPost will trigger a POST to the Forwarding Service. Then, this forwarding service app takes the webhooks data and uses SparkPost’s Transmission API endpoint to deliver messages to your configured recipient.

The flow looks something like this:

Forwarding Inbound Email with Heroku Diagram

As you can see, the forwarding service is pretty simple, but it gets the job done.

What’s Next? Have Ideas to Add to the Forwarding Service?

Start sending! If you want to see the dashboard of the SparkPost account the app is using, head over here for instructions.

Have ideas for improving the forwarding service or want to add a feature? Swing by GitHub to raise an issue or submit a PR. Your contributions to community projects really make SparkPost even more awesome.

I hope you find this service for forwarding inbound email with SparkPost useful. I’d love to hear how you use it!


Dev Survival Guide Blog Footer

Mandrill Template Migration

In the weeks since MailChimp announced that they have eliminated Mandrill as a stand-alone offering, our team has heard from lots of developers looking for a Mandrill alternative. And, as our lead product manager Amie Durr wrote about subaccounts and other enhanced SparkPost features, it’s been epic feedback that’s really helped us focus on what developers need to be productive.

And near the top of the list is making it easy to import Mandrill templates into SparkPost. That’s something we’ve heard, loud and clear. I sometimes think about email templates like Gollum thought about his ring: precious and powerful, and messing with them can have tricky side effects. Along with branding and structural layout, templates also are shot through with personalization markers—we call them substitution variables, Mandrill says merge tags—that are designed to tailor each recipient’s message with content meant just for them. When you couple that intrinsic complexity with the fact that our respective platforms work differently, you might fear you’ll have a potentially challenging migration task ahead, especially if you have lots of templates.

So, that’s why I’m really happy to announce our newest community project: an open source Mandrill template migration tool that makes it really easy to import Mandrill templates into SparkPost. (Or, as I like to call it, the Mandrill-to-SparkPost Templatizer 3000. That’s MST3K for short ;-).

For the impatient and technically minded, you can just grab the code from GitHub and follow the README. For the more prudent, read on for details about how it works, how to use it, where to get help—and also how you can help out with this project.

Deployment: Where Can I Get MST3K?

First things first: where can you get your hands on the tool?

The Easy Way: Heroku

If you’re developing with Heroku, you can just click this button to deploy MST3K into your Heroku account. Done.

Deploy to Heroku

Once the Heroku deployment completes, you’ll be presented with the web UI.

The Other Way: Run Locally

If you would rather deploy the tool into your own environment, here are the minimal steps. Note: you’ll need to have git  and Node.js 0.12+  installed.

Once the install is complete, you can access the web UI at http://localhost:3000/ .

Whether you deployed in Heroku or locally, the UI will look the same:


Mandrill-to-SparkPost Template Tool MST3K UI

How-To: How Do I Use MST3K?

Translating Mandrill Template Content

Once deployed, the simplest way to use the tool is interactively. Choose the “Translate Template Text” option. Paste your Mandrill template code into the left pane of the UI and hit “Translate!” Your translated output will be presented in the right-hand pane, ready to copy-and-paste into SparkPost.


Mandrill-to-SparkPost Template Tool MST3K Translation UI

Automating Mandrill Template Migration

Now, one-off, interactive conversions are all well and good, but you might prefer to automatically pull a template from Mandrill, translate it, and upload it directly into your SparkPost account. You probably want the migration to take both the plaintext and HTML template code into account, as well. I got you. Choose the “Migrate a Template” button on the main menu to begin. Here’s how it works:


Mandrill-to-SparkPost Template Tool MST3K Migration UI

Mass Mandrill Template Migration

OK, but what if you have lots of templates to migrate all at once? Because the UI is just a presentation layer on top of an API, it can be automated to fit your needs. Here’s an example which uses curl to call the migrate API endpoint directly:

You also can call the /api/translate  endpoint in a similar manner. For much more detail on the API, checkout the README and the code on GitHub.

Capabilities: What Can and Can’t MST3K Do?

So, what template capabilities translate from Mandrill to SparkPost?

If you are unsure of whether your template is migratable, the simplest option might be just to try it: the tool attempts to present useful error messages.

MST3K is designed to translate a Mandrill template that uses Handlebars-style syntax into equivalent SparkPost templates. Here, “Handlebars syntax” means templates that use curly brackets around their variables like this {{firstName}}.

To learn more, or for reference as you read on, it might be helpful to bookmark Mandrill’s Handlebars documentation and SparkPost’s substitutions variables docs. And, the official Handlebars documentation as well. Note that Mandrill has made a few syntax additions which are marked below as “Mandrillisms.”

The rest of the section gives samples of supported Mandrill syntax along with some equivalent SparkPost terminology for reference.

Basic Template Handlebars Syntax

Our MST3K migration tool can translate the basics like this:

Variable substitution
Conditional logic


Mandrill made a few additions to vanilla Handlebars which we can also translate:

Conditional expressions

Inline Helpers

Mandrill has a set of “content formatting helpers” which our migration tool understands but ignores, because there is no equivalent in SparkPost. The helpers currently accepted are the text case conversions: upper , lower , and title . The result post-translation is that those helpers are removed. Here’s an example:

Translated result
{{upper firstName}} {{firstName}}

Unsupported Elements

Finally, there are couple differences between a Mandrill template and a SparkPost template to be aware of when migrating:

  • Inline helpers: the url, date, and striptags helpers have no equivalent in SparkPost.
  • Block helpers: the unless and with block helpers have no equivalent in SparkPost.

MailChimp Template Syntax

By the way, what about MailChimp syntax? Although our support for MailChimp syntax is more limited, we do have early support for MailChimp syntax, thanks to a community contributor. Woot! Our community is pretty epic. Not sure if you’re using Mandrill or MailChimp syntax? Here’s the test: if your templates have {{curly brackets around substitution variables}}, you’re using Mandrill syntax. On the other hand, if you have variables in your template like this:  *|firstName|*, you’re using MailChimp syntax.

Help: Where Can I Learn More about MST3K?

As always, if you run into an issue, you have a how-to question, or you’d like to talk your situation through, come speak to us on SparkPost’s community Slack channel. For template and other code samples, integrations, and more, be sure to check out the SparkPost Developer Hub.

Contributions: How Can I Help Improve MST3K?

As with all community projects, MST3K stands on the shoulders of giants. To help make the tool as awesome as possible, we welcome all contributions from Mandrill and SparkPost users alike. Whether you open an issue, submit a pull request, or come share your experience with the community, we’d love to hear from you.

Let’s Build Something Awesome!

So, there it is: the Mandrill-to-SparkPost Templatizer 3000 is ready to help folks in need of a Mandrill alternative to make it easy to migrate Mandrill templates to SparkPost. I hope this addition to your toolbox serves you well!


Biz Eval Guide Blog Footer


Mandrill Heroku SparkPost Alternative

Welcome to SparkPost! This article will show how to migrate existing applications that send using SMTP from Mandrill to SparkPost. We’ll be adding some variables to your Heroku environment, and once that’s done, your app will need to be updated to use the new variables.

Domain Setup

SparkPost is setup with a sandbox domain which can be used to send up to 5 messages. To send more messages, create a sending domain via the SparkPost dashboard or the API.

In order to properly sign and authenticate messages sent through your account, there are some changes you’ll need to make up front. Verifying your sending domain is described in detail in our Support Center. This is one of the ways we protect your domain reputation, as well as our own reputation, from being tainted by e.g. phishing.

Installing the SparkPost add-on

First, lets install the add-on using the heroku  CLI:

Next, let’s confirm that the SparkPost API key is configured, and add it to the local environment variables:

Credentials and other sensitive configuration values should not be committed to source-control. In Git, you can exclude the

file with

Using the SparkPost config settings in your app

Here’s an ActionMailer example adapted from the Mandrill page:

Check out the SparkPost add-on page for more examples, and our API docs for examples of how we can handle generating messages for you using our Transmission API.

Thanks for choosing SparkPost! If you have questions, feel free to contact us on Twitter @SparkPost, ask a question on StackOverflow, or join us on Slack.

mandrill alternative

Surprised by news from Mandrill? We understand how frustrating that can be, and we have a Mandrill alternative for you. If you want to get started with SparkPost fast, our developer community has got you covered! Here’s a quick guide to getting started and getting your transactional emails up and running.


  1. Create a SparkPost account
  2. Configure sending domains, DKIM, and SPF
  3. Migrate to the SparkPost API
  4. Migrate your templates
  5. Build something awesome

1. Create a SparkPost Account

First, sign up for a free SparkPost account if you haven’t already. BTW, we’ve made the pricing really easy: up to 100,000 emails/month for free.

2. Configure Sending Domains, DKIM, and SPF

Check out our Getting Started Walkthrough video for an easy quick start. If video’s not your thing, simply follow the in-app SparkPost dashboard as it walks you through the basic account configuration steps.

3. Migrate to the SparkPost API

SparkPost’s API is fantastic. Here’s the API documentation. As a general rule, if you see it in our UI, you can access it in our API, too.

API Clients

Just want to get your hands in some code? You’ll find client libraries for the usual suspects on GitHub (and maybe some unusual ones, too):

Basic Concepts

Sending: Transmissions

The Transmissions endpoint is the business end of SparkPost’s email sending capability. It supports both transactional and non-transactional mail streams, templating, tracking, variable substitution, attachments and all the usual goodies. It’s documented here with sample code in all the usual languages.

Sending: SMTP

You can also use traditional SMTP to inject your mail into SparkPost. Here’s an intro video and documentation for the readers.

Receiving: Relay Webhooks

On the inbound side, you can use our Relay Webhooks along with Inbound Domains to accept inbound mail.

Tracking: Webhooks and Message Events

Beyond delivery and receipt, you can use Webhooks or the Message Events endpoint keep track of deliveries, bounces, opens, clicks, and all the other events SparkPost emits.

BTW, here’s a definitive reference to the available events.

Translating Mandrill to SparkPost Terminology

Mandrill and SparkPost use slightly different nomenclature to describe similar functions. Here’s a SparkPost terminology primer for those coming from Mandrill’s API.

Mandrill Says
SparkPost Says
merge vars substitution data SparkPost’s substitution data is similar to Mandrill’s with rich JSON-like structure.
messages/search-time-series metrics SparkPost Metrics offer time-series aggregate views on everything to do with your mail streams. They also power the reporting UI.




transmissions A single endpoint for all types of transmission.

 4. Migrate Your Templates

**Update: we have an awesome new Mandrill-to-SparkPost template migration tool! Now, it’s even easier to get started with SparkPost as a Mandrill alternative. If that sounds good to you, go get it and read how to use the tool to convert and migrate your Mandrill templates.

Like Mandrill, SparkPost’s templates use a handlebars-like syntax with {{braces}}  surrounding variables.  You can edit templates in the SparkPost UI or directly using the templates API endpoint.

If you’re just pulling variables into your template for simple personalization, you might be able to use your Mandrill templates unchanged with SparkPost.  Otherwise, here are a few syntax pointers.

Mandrill Syntax
SparkPost Syntax
nested variables

5. Build Something Awesome

Support Resources

  • General help: You can find help with most questions about SparkPost functionality, account configuration, and our web app in the SparkPost Support Center.
  • Developer stuff: For help with code and general developer support, the SparkPost Developer Hub is a great resource. And, if you want to chat something through with our developer community team, join our Slack community.



Easily deploy and scale your application with the SparkPost Heroku Email Add On

Heroku Sparkpost Email Add On

Heroku and SparkPost have the same viewpoint for developers: that they should be able to spend their time developing. Together our customers can easily deploy and scale their web applications on Heroku, while using SparkPost to create, send, and monitor the success of their emails.

Our developer advocacy team has been hard at work creating tutorial videos that will make the process as seamless as possible.

It’s never been a better time to try SparkPost on Heroku. Our 200k, 400k, 600k, and 800k message-a-month plans are exclusively available to Heroku users. Developers of all sizes, from startup to enterprise, can test our enterprise cloud solution without a huge upfront investment.

That’s the beauty of SparkPost, the platform built on the same technology that sends 25% of the world’s legitimate email. Start sending thousands of emails a month knowing you can scale to millions (or billions) on the solution that’s designed to scale for large volume senders.

Need help getting started? No problem. Check out our support page for more info.

Looking for a dedicated IP, white glove support, and unparalleled inbox placement? We can help with that too. For more information reach out to

SparkPost is available as an email add-on in the Heroku marketplace! Developers can leverage the deliverability, scalability, and speed of the SparkPost application without leaving the Heroku development platform.

The add-on makes it easy to automatically create a new SparkPost account through the standard Heroku add-on mechanism, and all billing is done through your existing Heroku account.

Setting up your application to use the SparkPost email add-on in Heroku is easy. Check out the details in the Heroku Dev Center to get up and running. SparkPost’s developer advocacy team has put together a great video showing how it works:

If you’re already logged in with the Heroku CLI Toolbelt, here are some quick tips to get started:

  1. Use heroku addons:create sparkpost to install the SparkPost add-on in your app
  2. Accept the terms of use heroku addons:open sparkpost
  3. Configure your sending domain for use with and you’re ready to start sending email in production!

More details about our Heroku email add on are listed here.

It goes without saying that Heroku developers can take advantage of all of SparkPost’s goodness: real-time analytics in the dashboard, via API, and with webhooks; great API documentation and developer support; the best inbox placement in the industry, period; and some serious developer love.

We’re excited to help Heroku make the most of the world’s most powerful email platform. That’s why we’re offering exclusive pricing plans for the Heroku platform (including up to 100,000 free emails per month).

Let’s build something awesome with SparkPost and Heroku. Get started today.