I really like Digital Ocean for its no-fuss, economical yet powerful servers.
Recently, I hit a snag trying to configure subdomain for mailgun using digital ocean’s DNS settings. No matter what I did, mailgun was failing to verify the domain. After sipping few cups of coffee and contemplating meaning of life, when microsoft is demo-ing holographic minecraft and I am struggling to configure a stupid mail domain, I woke from my slumber and finally got things to work and sharing the details below for others:
Step 1. Add the subdomain, let’s say mail.example.com, as new domain in Digital Ocean. Trying to add subdomain in the DNS settings of example.com itself, will mostly not work.
Step 2. Now in this new domain, add mailgun MX details as below. The settings shared in mailgun will not work, if used as is. You need to take care of few things as given below.
|Record Type||Name||Value||Thing to take care of|
|A||@||IP Address||use @ not domain name|
|CNAME||mailgun.org.||dot at the end of mailgun.org|
|MX||10||mxa.mailgun.org.||dot at the end of mailgun.org|
|MX||10||mxb.mailgun.org.||dot at the end of mailgun.org|
|TXT||@||“v=spf1 include:mailgun.org ~all”||wrap the value in double quotes|
|TXT||krs._domainkey||“k=rsa; p=BIGCHARACTERSTRING”||wrap the value in double quotes. And the Name should be krs._domainkey not krs._domainkey.subdomain.domain.com|
|NS||ns1.digitalocean.com.||dot at the end|
|NS||ns2.digitalocean.com.||dot at the end|
That’s it! You are done.
If you are wondering, why should we configure a subdomain – its a good practise to configure subdomain for promotional or transactional emails because of the following:
- Let’s say your domain is example.com and subdomain is mail.example.com
- You can send emails from google apps account, mailgun, mandrill, whatever – using any email configured with example.com. For example, firstname.lastname@example.org or email@example.com
- But you cannot receive emails for a single domain. So if you have configured google apps or some other service to receive emails, you cannot configure another service, like mailgun, to receive emails.
- Hence, you need to setup a subdomain or some other domain to receive emails.
- Apart from the above reason, separation of concerns is good while configuring subdomains, for example
– mail1.example.com for transactional emails
– mail2.example.com for promotional emails
This separates the reputation of subdomains and hence the reputation of promotional emails will not affect transactional emails delivery.
Hope this helps someone!