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.
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 “Whitelabels” 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 whitelabel” and turned on “automated security” so that SendGrid can manage my SPF & DKIM settings for me.
You’ll need to set up 3 CNAME records in your DNS. The confirmation page from the whitelabel 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.
So MANDRILL_USERNAME needs to become SENDGRID_USERNAME, MANDRILL_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:
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.