Mailgun Setup - Namecheap Domain Setup

Modified on: Wed, 1 Jul, 2026 at 6:53 AM

EMAIL INFRASTRUCTURE
Step-by-Step Mailgun Setup: Namecheap Domain Setup
Sign up for Mailgun, add your domain, and publish the TXT, MX, and CNAME records in Namecheap so your emails verify and deliver.
What You'll Learn

This guide covers creating a Mailgun account, adding a sending domain, choosing between a main domain and a subdomain, and publishing the 5 required DNS records — 2 TXT, 2 MX, and 1 CNAME — inside Namecheap's Advanced DNS settings.

1

Sign Up for Mailgun

Create your account at Mailgun.com.

2

Verify Your Email Address

Check your email inbox to verify the email address you signed up with.

Mailgun signup confirmation screen
Email verification confirmation screen
3

Add a New Domain in Mailgun

Log in to Mailgun and click Sending → Add New Domain.

Sending menu with Add New Domain option in Mailgun
4

Choose a Main Domain or Subdomain

If your domain is companyname.com, you can set up either the main domain or a subdomain with Mailgun.

Option A
Main Domain

If you add the main domain, it should not be used with Google Workspace or any other email provider.

Option B
Subdomain

To set up a subdomain with Mailgun, you can type anything_here.companyname.com. Examples:

  • mg.companyname.com
  • replies.companyname.com
  • support.companyname.com
Note

Set up the domain or subdomain under the US region, not EU. Then click Add domain.

Add domain form in Mailgun with US region selected
Setup Guide
Now let's publish 5 DNS records in Namecheap
2 TXT records, 2 MX records, and 1 CNAME record — follow each sub-step carefully.
5

Add Your DNS Records in Namecheap

Log in to Namecheap.com, then click Domain List → Manage.

Namecheap Domain List with Manage button

Click Advanced DNS — this is where we'll add all 5 DNS records.

Namecheap Advanced DNS tab
DNS Record 1 of 5
To Add the 1st TXT Record

Click Add New Record.

Add New Record button in Namecheap Advanced DNS

Select TXT Record from the dropdown.

TXT Record selected in record type dropdown
TXT record row in Namecheap DNS table

A. Host: depending on the subdomain you're setting up:

  • mg.companyname.com → host name is mg
  • replies.companyname.com → host name is replies
  • Main domain (companyname.com) → host name is @

B. Value: head back to Mailgun and copy the first TXT record — it will look like v=spf1 include:mailgun.org ~all — and paste it here.

TXT record value field with SPF record pasted

C. Click the green check to save.

DNS Record 2 of 5
To Add the 2nd TXT Record

Click Add New Record again, and select TXT Record from the dropdown.

Add New Record button for the second TXT record
TXT Record type selected for the second record
Second TXT record row in Namecheap DNS table

A. Host: this one is a bit tricky — copy everything from the beginning until the subdomain part. Do not copy the main domain.

Mailgun host value highlighted up to the subdomain

Examples — copy the highlighted part:

ScenarioScreenshot
Using a subdomainExample host value when using a subdomain
Using the main domainExample host value when using the main domain

B. Value: paste the second, longer TXT record from Mailgun here.

Second TXT record value pasted into Namecheap

C. Click the green check to save.

DNS Record 3 of 5
To Add the 1st MX Record

Scroll down to Mail Settings and switch the dropdown to Custom MX.

Mail Settings dropdown switched to Custom MX
Heads Up

Switching to Custom MX will affect your existing Google Workspace account for incoming mail on the main domain if Gmail was originally selected. Make sure you're using a subdomain for Mailgun. See Can I Use the Same Domain Name for Mailgun and for Google Apps (Or Another Email Server)?

You'll need to add back the 5 MX records for Google Gmail:

HostTTLPriorityValue
@36001ASPMX.L.GOOGLE.COM
@36005ALT1.ASPMX.L.GOOGLE.COM
@36005ALT2.ASPMX.L.GOOGLE.COM
@360010ALT3.ASPMX.L.GOOGLE.COM
@360010ALT4.ASPMX.L.GOOGLE.COM

Once all five MX records above are added back, add the Mailgun MX record. Click Add New Record.

Add New Record button for the first MX record
MX record row being configured in Namecheap

A. Host: depending on the subdomain you're setting up:

  • mg.companyname.com → host name is mg
  • replies.companyname.com → host name is replies
  • Main domain (companyname.com) → host name is @

B. Value: mxa.mailgun.org

C. Priority: 10

D. Click the green check to save.

First MX record saved in Namecheap
DNS Record 4 of 5
To Add the 2nd MX Record

A. Host: depending on the subdomain you're setting up:

  • mg.companyname.com → host name is mg
  • replies.companyname.com → host name is replies
  • Main domain (companyname.com) → host name is @

B. Value: mxb.mailgun.org

C. Priority: 10

D. Click the green check to save.

Second MX record saved in Namecheap
DNS Record 5 of 5
To Add the CNAME Record

Scroll back up to the Host Records section and click Add New Record.

Add New Record button for the CNAME record

Select CNAME Record from the dropdown.

CNAME Record selected in record type dropdown

Head back to Mailgun to copy the host name — copy everything from the beginning until the subdomain part. Do not copy the main domain.

Mailgun CNAME host value to copy

Go back to Namecheap:

Namecheap CNAME record row

A. Host: depending on the subdomain you're setting up:

  • mg.companyname.com → host name is email.mg
  • replies.companyname.com → host name is email.replies
  • Main domain (companyname.com) → host name is email

B. Value: mailgun.org

C. Click the green check to save.

Now that all 5 records have been added, go back to Mailgun and click Verify DNS Settings. Click the same button again if some records still aren't showing a green checkmark.

Mailgun Verify DNS Settings results
6

Get Your API Key & Send a Test Email

Once all the DNS records are added and verified, grab your key from Mailgun API Key: Where to Find It in Mailgun and Add It to the Platform.

You're Almost Done

Send a test email to confirm everything works. See How to Send a Test Email in the Conversation for the steps.

Video Recap
8

Frequently Asked Questions

Q: Will switching to Custom MX break my existing Gmail or Google Workspace email?
It can, if you're adding the MX records to your main domain and it's already used with Google Workspace. Re-add all 5 Google MX records alongside the Mailgun ones, and consider using a subdomain instead to avoid the risk entirely.
Q: What's the difference between the "Host" value for the TXT/MX records and the CNAME record?
For TXT and MX records, the host is just your subdomain (e.g. "mg"). For the CNAME record, Namecheap expects "email.mg" — the tracking subdomain Mailgun uses for click and open tracking.
Q: My records aren't showing a green checkmark after verifying — what should I do?
DNS changes can take time to propagate. Double-check each host and value against what Mailgun shows, then click Verify DNS Settings again after a few minutes.
Q: Why do I need two separate TXT records?
The first TXT record is your SPF record, which authorizes Mailgun to send on your behalf. The second, longer TXT record is your DKIM key, which cryptographically signs your outgoing mail.
Q: Do I need to copy the exact values shown in this guide, or the ones from my own Mailgun account?
Always copy the exact host and value strings shown in your own Mailgun dashboard — the mxa.mailgun.org and mxb.mailgun.org values are standard, but your TXT record values are unique to your domain.
Q: Can I use this same process for a domain provider other than Namecheap?
The record types and values are the same everywhere, but the interface for adding them differs by provider. Check the related provider-specific setup guides below.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article