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, “domain.com” is just a placeholder for your domain name and I’ll show both top level (“domain.com”) and subdomain (“mg.domain.com”) implementations.
Record 1
The first record’s name will be something like:
// top level
domain.com
// subdomain
mg.domain.com
Instead, remove the domain name like so:
// top level becomes
@
// subdomain becomes
mg
Add double quotes to the text value:
// mailgun
v=spf1 include:mailgun.org ~all
// you'll use
"v=spf1 include:mailgun.org ~all"
Save the record.
Record 2
Follow the same pattern for the next record:
// top level
// - mailgun
mx._domainkey.domain.com
// - you'll enter
mx._domainkey
// subdomain
// - mailgun
mx._domainkey.mg.domain.com
// - you'll enter
mx._domainkey.mg
Note: Your string may not include “_domainkey.” Don’t worry, just use whatever MailGun gives you in its place and remove “domain.com”.
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
email.domain.com
// - You'll Enter
email
// subdomain
// - MailGun
email.mg.domain.com
// - You'll Enter
email.mg
The only change you’ll make to this cname’s hostname will be to add a period at the end:
// MailGun
mailgun.org
// You'll Enter
mailgun.org.
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!