DNS (Domain Name System) records are instructions that tell the internet how to handle your domain. When integrating Mailgun for email services, you'll need to add specific DNS records to authenticate your domain and allow Mailgun to send emails on your behalf.

Step 1: Adding a New Domain in Mailgun

  1. Log into your Mailgun account and navigate to the "Sending" section on the left-hand side.
  2. Click on "Domains" and then select "Add New Domain."
  3. Enter your domain name (e.g., mg.example.com). Regardless of your location, make sure the region is set to "US" for compatibility.
  4. Click "Add Domain" to proceed. Mailgun will then give you a list of DNS records to add to your Namecheap domain.

Step 2: Adding DNS Records in Namecheap

TXT Records:

  • Log into your Namecheap account, find your domain, and click "Manage."
  • Go to "Advanced DNS" and click "Add New Record."
  • Select "TXT Record" and enter the hostname (e.g., mg.example.com) and the value provided by Mailgun. Repeat this step for each TXT record provided by Mailgun.

MX Records:

  • In the "Advanced DNS" section, find the MX records area.
  • Click "Add New Record," select "MX Record," and enter the hostname (mg), value, and priority (10) as provided by Mailgun. Repeat for any additional MX records.

CNAME Record:

  • Still in the "Advanced DNS" section, click "Add New Record" and select "CNAME Record."
  • Enter the hostname (e.g., email.mg) and the value provided by Mailgun.

Step 3: Verifying DNS Settings in Mailgun

  1. Return to your Mailgun account and navigate to the domain settings.
  2. Click "Verify DNS Settings." Changes can take a while to propagate, typically 24 to 48 hours, though it's often quicker than that.
  3. Once verified, you should see green check marks next to each DNS record in Mailgun, confirming the setup is complete.

Step 4: Retrieving the API Key

  1. In Mailgun, go to "API Keys" and locate your API key.
  2. Copy this key for use when integrating Mailgun with your email services or other applications.

Troubleshooting Tips

DNS Propagation

  • If your DNS records aren't verifying, bear in mind it can take up to 48 hours for DNS changes to propagate worldwide.

Correct Region Setting

  • Make sure the region is set to "US" when adding your domain in Mailgun, as this is currently required for proper functionality.

Double-Check Values

  • Check that all values are copied exactly as provided by Mailgun, without any additional spaces or characters.