Setting up Mailgun DNS records with Namecheap domains

Setting up Mailgun DNS records with Namecheap domains

Syndicated on Medium.

Mailgun is a service that lets developers programmatically send and receive emails. Namecheap is a domain registrar. I wanted to setup Mailgun to use custom email with the domain I manage using Namecheap. But I stumbled on some issues with settings.

I eventually got it working, and Iโ€™m sharing my solutions here just in case someone else hits the same blocks with these (or other) email and domain services.

Letโ€™s get to it!

By this point, you have already added your domain to Mailgun. Now you need to add Mailgun-related DNS records to your domain.

While setting up, I followed the steps given by Mailgun. For each record it came down to:

  1. Choosing a type of record from the dropdown
  2. Setting the hostname
  3. Entering the DNS value, which is given to me by Mailgun (Iโ€™ve not included this in the screenshots later on, because security ๐Ÿ’๐Ÿฝ)

But their recommended entries (see screenshots) at steps 2 did not work for me.

Instead I did the following.


SPF & DKIM

Mailgun: TXT records (with my domain purpled-out).

For the first TXT record, it asked me to put the domain as the hostname. I used the @ sign instead, because Namecheap uses the โ€œ@โ€ sign to represent your domain.

For the second TXT record, it said to enter a hostname that was foo.bar.my-domain. Instead I used only the foo.bar portion.


MX records

Mailgun: MX records

MX records are mail server records. In the Mail Settings section of the Advanced DNS panel on your Namecheap interface, select Custom MX so you can enter your Mailgun records.

The section about MX records in the Mailgun guide did not mention it but you need to set the host as your domain. So under host, put @. Also just set TTL (time to live) as Automatic.

Now, Mail Settings on the Advanced DNS panel should look like this.

Namecheap: Mail Settings

CNAME record

By now the setup is enough for Mailgun to verify your DNS. This last one is considered optional.

Mailgun: Optional DNS records if you want tracking (with my domain purpled-out).

Instead of entering email.your-domain in the hostname field, just enter email as the hostname. Also remember, that here in the value field, the page tries to be smart. Mail server names should end with a period (โ€œ.โ€). If the form field recognizes the mail server name (as it does with Mailgun), it will automatically insert a period. Donโ€™t let it throw you off. Thatโ€™s ok.


The settings Iโ€™ve described above should let you use Mailgun with your domain. In case you stumbled on the same blocks I encountered, I hope you find this helpful! ๐Ÿ’›

Show Comments