Mailgun domain not verified: the DNS records and how to check them
Mailgun verifies a sending domain from two TXT records: SPF (v=spf1 include:mailgun.org ~all) and DKIM (a <selector>._domainkey TXT record, or two CNAMEs if Automatic Sender Security is on). The MX records and the tracking CNAME are for receiving mail and for open/click tracking. Copy the exact values from Domain settings › DNS records, check them with dig, then click Check status or call PUT /v4/domains/{name}/verify. DNS changes can take 24 to 48 hours to propagate.
- Copy the records Open Send › Sending › Domain settings › DNS records for the domain and copy each record's host and value.
- Add them at your DNS host Create the SPF and DKIM TXT records (or the DKIM CNAMEs), plus the MX and tracking CNAME if you receive or track mail through Mailgun.
- Check they resolve Query each record with dig or a public DNS checker and compare the values with the control panel.
- Re-run verification Click Check status, or call PUT /v4/domains/{name}/verify on the API host for the domain's region.
The records Mailgun asks for
Example for the sending domain mg.example.com. Always copy values from your own control panel: the DKIM selector and key are unique to your domain.
| Type | Host | Value | Purpose |
|---|---|---|---|
| TXT | mg.example.com | v=spf1 include:mailgun.org ~all | SPF: lets Mailgun's servers send for the domain |
| TXT | <selector>._domainkey.mg.example.com | The DKIM public key from the control panel | DKIM signing |
| CNAME ×2 | pdk1._domainkey.mg.example.com, pdk2._domainkey… | Targets like pdk1._domainkey.….dkim1.mailgun.com | DKIM with Automatic Sender Security, instead of the TXT |
| MX ×2 | mg.example.com | US: 10 mxa.mailgun.org, 10 mxb.mailgun.org; EU: mxa.eu.mailgun.org, mxb.eu.mailgun.org | Receiving and Routes; also lets Mailgun see delayed bounces |
| CNAME | email.mg.example.com | US: mailgun.org; EU: eu.mailgun.org | Open, click and unsubscribe tracking |
Mailgun's help centre says the two TXT records are all you need to send, while the verification table in its docs also lists the MX and CNAME. Add the MX records unless the hostname already receives mail elsewhere, because pointing it at Mailgun would move that mail.
Why a record stays unverified (most common first)
- Your DNS host appended the zone. Many panels add your domain to whatever you type in the host field, so
mg.example.combecomesmg.example.com.example.com. Enter justmg(ormx._domainkey.mg) if your panel works that way. - Two SPF records on one host. Only one is allowed. Merge them:
v=spf1 include:_spf.example.net include:mailgun.org ~all. Keep the whole record under 10 DNS lookups. - A CNAME on the same hostname. A CNAME takes precedence over the TXT records next to it, so SPF never resolves. Remove the CNAME or send from another subdomain.
- The DKIM value was cut or mangled. 2048-bit keys are long, and some DNS providers need the value split into two strings. Check that nothing is missing at the end and that no extra quotes were added.
- Mailgun hasn't re-checked yet. The records resolve publicly, but the domain still says Unverified. Use Check status (below).
Mailgun may show several DKIM keys, some of them Unverified, after key rotation or after switching to Automatic Sender Security. They don't all need to verify; only the key the domain uses does.
Check the records yourself
dig -t TXT mg.example.com +short
"v=spf1 include:mailgun.org ~all"
dig -t TXT mx._domainkey.mg.example.com +short # use your selector
dig -t MX mg.example.com +short
dig -t CNAME email.mg.example.com +shortMailgun suggests checking both a local query and a public one (for example whatsmydns.net), because a DNS server inside your network can answer differently from the internet. If a public check shows the right value, the record is published; if it doesn't, fix it at the provider whose nameservers actually serve the domain.
Make Mailgun check again
Mailgun re-checks on its own, but you can force it: Send › Sending › Domain settings › DNS records, select the domain, click Check status. Or over the API, on the host of the domain's region:
curl -s --user "api:$MAILGUN_API_KEY" -X PUT \
https://api.mailgun.net/v4/domains/mg.example.com/verifyThe response starts with "message": "Domain DNS records have been updated" and lists sending_dns_records and receiving_dns_records, each with a valid field. The domain's state is active, unverified or disabled. A 404 with Domain not found usually means you called the wrong region's host.
What an unverified domain costs you
- Mailgun applies a sending limit of 300 emails a day to domains that aren't verified.
- Recipients may see "sent via Mailgun.org".
- Without MX records pointing at Mailgun, delayed bounces (non-delivery reports sent after the SMTP session) never reach Mailgun, so they won't appear as failures.
Once the domain verifies, publish a DMARC record for it too; see SPF, DKIM and DMARC for transactional email.
Questions
How long does Mailgun domain verification take?
Usually soon after the records resolve, but DNS changes can take 24 to 48 hours to propagate. If the records are correct publicly after 24 hours, run Check status.
Do I need Mailgun's MX records to send?
Mailgun's help centre says only the SPF and DKIM TXT records are required to send. MX records are for receiving mail through Mailgun and for catching delayed bounces, and they would redirect any mail that hostname already receives.
Are the DNS records different for an EU domain?
Yes, for receiving and tracking: the MX hosts are mxa.eu.mailgun.org and mxb.eu.mailgun.org, and the tracking CNAME points at eu.mailgun.org. Copy the values your control panel shows for the domain.
Should I use a subdomain?
Mailgun recommends one, such as mg.example.com. It keeps the SPF and MX records apart from your main domain's mail.
Related
- SPF, DKIM and DMARC for transactional email: setupSign with DKIM on your domain, align SPF via a custom Return-Path, start DMARC at p=none. The records for Postmark, Mailgun, SendGrid and Resend.
- Mailgun EU region API: US vs EU endpoints and errorsMailgun EU domains use api.eu.mailgun.net, US domains api.mailgun.net. The key works in both, so the wrong host says the domain doesn't exist.
- Mailgun sandbox domain: authorized recipients and limitsA Mailgun sandbox domain only sends to up to 5 authorized recipients who clicked the activation link. How to add them, and how to send to anyone else.
- Custom Return-Path domain: why and how to set it upA custom Return-Path puts bounces on your own subdomain so SPF aligns for DMARC. On Postmark: CNAME pm-bounces.example.com to pm.mtasv.net, then verify.
- Bouncewise Mailgun API key: which key to useUse a Mailgun account API key (Admin or Support role), not a domain sending key. Bouncewise finds your US and EU domains with one key.