Configuring MailGun with DigitalOcean’s DNS

So, this had me cussing the heavens for about 3 days. If you’ve found this post, you’ll know exactly what I mean. When setting up a MailGun domain, DNS entries are required to verify your domain with the service. The default entries, as provided by MailGun, may work great for other DNS providers however they do not work out-of-the-box with DigitalOcean‘s DNS management. This is how you’ll need to tweak them to get your domain verified.

Note: If you’re going with the subdomain route as advised by MailGun, you do not need to setup a new domain in DigitalOcean (Networking > Domains). You can use your domain name’s DNS records.


TXT Records

The provided TXT records are required to send mail through MailGun. Each record has a name and a text value. For the rest of this article, “” is just a placeholder for your domain name and I’ll show both top level (“”) and subdomain (“”) implementations.

Record 1

The first record’s name will be something like:

// top level // subdomain

Instead, remove the domain name like so:

// top level becomes @ // subdomain becomes mg

Add double quotes to the text value:

// mailgun v=spf1 ~all // you'll use "v=spf1 ~all"

Save the record.

Record 2

Follow the same pattern for the next record:

// top level // - mailgun // - you'll enter mx._domainkey // subdomain // - mailgun // - you'll enter

Note: Your string may not include “_domainkey.” Don’t worry, just use whatever MailGun gives you in its place and remove “”.

Modify the text value by wrapping it in double quotes:

// MailGun k=rsa; p=REALLYLONGSTRINGHERE // You'll Enter "k=rsa; p=REALLYLONGSTRINGHERE"

Text records are done. Almost home.

DNS Tracking Record

On to the tracking cname


// top level // - MailGun // - You'll Enter email // subdomain // - MailGun // - You'll Enter

The only change you’ll make to this cname’s hostname will be to add a period at the end:

// MailGun // You'll Enter

That’s it. Just wait for propagation and you’re done. I can confirm that both of these methods (domain and subdomain) work as outlined above.


Let me know if you have any questions. Happy MailGunning!