Replacing the Mandrill Heroku Add-on with the SendGrid Add-on


February 26, 2016
Written by
SendGrid Team
Contributor
Opinions expressed by Twilio contributors are their own

Replacing the Mandrill Heroku Add-on with the SendGrid Add-on

In light of Mandrill shutting down it’s Heroku add-on, we know there are some Heroku users who are looking for an alternative. Fortunately, Glenn Gillen, who just switched his app ContentFocus from Mandrill to SendGrid, put together a helpful how-to on how to update your ruby apps to use SendGrid.

Below are instructions adapted from Glenn’s post:

Install the SendGrid Add-On

Open up your terminal and use the Heroku CLI to install the add-on.

Configure SendGrid

You'll need to set up a bunch of things to verify your new account and maximize your email deliverability. And you don't want any of these things impacting your app after you've switched over.



Confirm your email address. And then move straight onto "sender authentication" in the menu on the left. Add a new domain, and set it up to be a new subdomain on whatever your domain is (i.e., for me it's em+contentfocus.io). I set it to be the "default sender authentication" and turned on "automated security" so that SendGrid can manage my SPF & DKIM settings for me.

Update DNS

You'll need to set up 3 CNAME records in your DNS. The confirmation page from the sender authentication settings will give you the aliases and values you need to use. Once they're set up, click the "Validate Record" button to make sure it's all worked. It took less than 10 seconds for mine to come live. DNS being what it is it could take a few hours though. Your mileage may vary.

Update Your Apps

I've accumulated these apps over a number of years. It's unlikely they're all configured the same way, and there's no way I can remember all the different approaches. Actually I can't even remember the last approach! My apps are in Ruby, but this approach should work for any app. We'll use ack to search the code for the Mandrill ENV vars.



Found it!



So MANDRILL_USERNAME needs to become SENDGRID_USERNAMEMANDRILL_APIKEY becomes SENDGRID_PASSWORD, and I'll need to change the address to point to 'smtp.sendgrid.net'.

When switching to SendGrid, you'll also need to make sure that authentication mode is set to :plain too. So the updated values look like:

Ship it!

We're done. Run the tests, commit the changes, git push heroku master. Tail the logs and watch your exception tracker just to make sure it's all working fine. The only step remaining is to remove the old add-on.


Recommended For You



Most Popular


Send With Confidence

Partner with the email service trusted by developers and marketers for time-savings, scalability, and delivery expertise.