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.
Sign Up for Mailgun
Create your account at Mailgun.com.
Verify Your Email Address
Check your email inbox to verify the email address you signed up with.


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

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.
If you add the main domain, it should not be used with Google Workspace or any other email provider.
To set up a subdomain with Mailgun, you can type anything_here.companyname.com. Examples:
- mg.companyname.com
- replies.companyname.com
- support.companyname.com
Set up the domain or subdomain under the US region, not EU. Then click Add domain.

Add Your DNS Records in Namecheap
Log in to Namecheap.com, then click Domain List → Manage.

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

Click Add New Record.

Select TXT Record from the dropdown.


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.

C. Click the green check to save.
Click Add New Record again, and select TXT Record from the dropdown.



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

Examples — copy the highlighted part:
| Scenario | Screenshot |
|---|---|
| Using a subdomain | ![]() |
| Using the main domain | ![]() |
B. Value: paste the second, longer TXT record from Mailgun here.

C. Click the green check to save.
Scroll down to Mail Settings and switch the dropdown to Custom MX.

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:
| Host | TTL | Priority | Value |
|---|---|---|---|
| @ | 3600 | 1 | ASPMX.L.GOOGLE.COM |
| @ | 3600 | 5 | ALT1.ASPMX.L.GOOGLE.COM |
| @ | 3600 | 5 | ALT2.ASPMX.L.GOOGLE.COM |
| @ | 3600 | 10 | ALT3.ASPMX.L.GOOGLE.COM |
| @ | 3600 | 10 | ALT4.ASPMX.L.GOOGLE.COM |
Once all five MX records above are added back, add the Mailgun MX record. Click Add New 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: mxa.mailgun.org
C. Priority: 10
D. Click the green check to save.

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.

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

Select CNAME Record from the 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.

Go back to Namecheap:

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.

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.
Send a test email to confirm everything works. See How to Send a Test Email in the Conversation for the steps.
Frequently Asked Questions
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article

