Mailgun recommends sending from a subdomain like mg.yourdomain.com, and that one choice makes everything simpler: the records live on the subdomain, your main SPF record doesn't change, and DMARC still passes for your main domain. This guide follows that setup.
Before you start
- A Mailgun account, and whether you're in the US or EU region. Some record values differ by region.
- Access to your DNS host, wherever your domain's DNS records are managed (Cloudflare, GoDaddy, Namecheap, Route 53 and so on). This isn't always where you bought the domain. Rigcheck shows your DNS host at the top of your results.
Step 1: Add your sending domain
- In Mailgun, go to Send → Sending → Domains (or Domains in older layouts) and click Add new domain.
- Enter a subdomain such as
mg.yourdomain.com. - Turn on Automatic Sender Security if offered. Mailgun then rotates your DKIM keys for you.
Step 2: Add the DNS records
Mailgun lists the records under the domain's DNS records or verification page. For a subdomain called mg:
| Type | Name | Value | What it does |
|---|---|---|---|
TXT | mg | v=spf1 include:mailgun.org ~all | SPF for the subdomain |
CNAME or TXT | From Mailgun (like pdk1._domainkey.mg) | From Mailgun | DKIM: two CNAMEs with Automatic Sender Security, or one TXT key without it |
MX | mg | 10 mxa.mailgun.org and 10 mxb.mailgun.org | Bounces and replies |
CNAME | email.mg | mailgun.org | Open and click tracking |
EU accounts use mxa.eu.mailgun.org, mxb.eu.mailgun.org and eu.mailgun.org instead. Copy every value from Mailgun rather than from this table.
The SPF record goes on mg, not your root domain, so it's separate from your main SPF record. Don't add include:mailgun.org to your main record unless you send through Mailgun as your root domain itself.
Most DNS hosts add your domain automatically, so enter names in the short form your provider shows. Typing the full name can produce something like s1._domainkey.yourdomain.com.yourdomain.com, which silently fails. If you're not sure, add one record and look at how your host displays it.
If your DNS is on Cloudflare, set every CNAME record to DNS only (grey cloud), not proxied. A proxied record hides the CNAME, and verification fails.
Step 3: Verify
Back in Mailgun, click Verify DNS settings. Mailgun allows up to 48 hours, though it's usually much faster.
DMARC
If your domain has no DMARC record yet, add a TXT record named _dmarc:
_dmarcTXTv=DMARC1; p=none; rua=mailto:dmarc@yourdomain.comIf you already have one, keep it. A domain can only have one DMARC record, and it covers mail from Mailgun too. Start with p=none, then tighten it once your reports look clean: DMARC p=none vs quarantine vs reject walks through it.
The DMARC record goes on your main domain. Mail from mg.yourdomain.com passes DMARC for yourdomain.com under the default relaxed alignment.
Confirm it works
- Run your domain through Rigcheck. Check your sending subdomain: SPF should pass, and DKIM should show your Mailgun keys. Check your main domain for DMARC.
- Send a test message through Mailgun to a personal Gmail address. Open it, tap the three-dot menu and choose Show original. You should see PASS next to SPF, DKIM and DMARC, with your own domain listed for each.