Configuring SMTP with Mandrill on DigitalOcean

Mandrill, by the company behind MailChimp, allows you to send emails from your application. Here's a quick guide to show you how to set it up with DigitalOcean as your domain's nameserver.

Sign Up with Mandrill

Sign Up for a free Mandrill account.

Click the button that says Set Up Your Sending Domain and have the DKIM and SPF values ready. They reassure the recipient's mail server that Mandrill is authorized to send emails with that domain.

DigitalOcean DNS

Go to your DigitalOcean admin panel, under Networking > Domains, add your domain.

Next, add the two TXT entries. You don't need to escape the semicolons but do ensure you put quotes around the both records' values.

For DKIM, use mandrill._domainkey as the record name, and v=DKIM1\; k=rsa\; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrLHiExVd55zd/IQ/J/mRwSRMAocV/hMB3jXwaHH36d9NaVynQFYV8NaWi69c1veUtRzGt7yAioXqLj7Z4TeEUoOLgrKsn8YnckGs9i3B3tVFB+Ch/4mPhXWiNfNdynHWBcPcbJ8kjEQ2U8y78dHZj1YeRXXVvWob2OaKynO8/lQIDAQAB\; as the value.

DigitalOcean will automatically append the domain name to your DNS records, so do not use

For SPF, use @ as the record name, and "v=spf1 ?all" as the value.

Get SMTP Credentials

Go back to Mandrill and press "Test DNS Settings" to ensure you've set up everything correctly.

Then go back to the Settings page and click + New API Key, this will be used as your password.

Keep your password secret. Anyone with the password can send emails as you. You may want to change your password regularly, but be sure to update your code or environment variable.

You're now ready to send emails using SMTP via Mandrill!

Daniel Li

Full-stack Web Developer in Hong Kong. Founder of Brew.

Hong Kong