Mailgun · Domain authentication
Mailgun mail shows “via mailgun.org” or lands in spam: authenticate your sending subdomain
The “via” label is the visible symptom: receivers cannot yet tie this message to your domain, because your domain has not been verified in Mailgun.
The fast answer
Do not repoint your root domain’s MX records to Mailgun, and do not change anything yet if you have not diagnosed which record is missing. The correct first move is a dedicated sending subdomain — for example mg.yourdomain.com — with Mailgun’s own SPF and DKIM records published on that subdomain, then verified in Mailgun. The two TXT records (SPF and DKIM) are the required pair; MX and tracking records are optional and conditional, as explained below.
What you are looking at, in plain words
Mailgun will only send as your domain once you prove you own it. Verification is a DNS exercise: Mailgun shows you the exact records for your domain, you publish them where your domain’s nameservers live, and Mailgun checks them from the public internet. Until that check passes, mail goes out under Mailgun’s own domain — hence “via mailgun.org” — and receivers have no reason to trust it as yours.
| Record | Required? | What it does |
|---|---|---|
| SPF TXT | Yes | Authorises Mailgun’s servers to send for the sending subdomain |
| DKIM TXT (or CNAMEs with Automatic Sender Security) | Yes | Signs mail with a key receivers can verify against your DNS |
| MX | Only if Mailgun should receive mail for that exact subdomain | Routes inbound mail for the subdomain to Mailgun |
| Tracking CNAME | Only for open, click and unsubscribe tracking on your own domain | Points tracking links at Mailgun |
Step 0 — Prove which part is failing
- Open Mailgun → Sending → Domains and read the domain’s status. “Unverified” means at least one record is missing or not yet visible; it does not tell you which one, so check each record below individually.
- Query public DNS yourself. Mailgun’s own help recommends checking with both a local tool (
dig -t TXTornslookup) and a public propagation checker, because a record saved in your panel is not the same as a record visible worldwide. - Check where your nameservers live. Edit DNS wherever your domain’s nameservers point — registrar, Cloudflare, or host — not in a panel whose nameservers your domain does not use.
- Confirm you are not about to break inbound mail. If your root domain already receives business mail, its MX records stay exactly as they are. That is the whole point of the subdomain pattern.
The fixes, in order
- Add a sending subdomain in Mailgun. In Sending → Domains, add the subdomain (for example
mg.yourdomain.com), not your root domain. Mailgun generates the records for that subdomain; copy them exactly — do not copy values from a blog post or another account, because DKIM keys are per-domain. - Publish the SPF TXT record on the subdomain. Mailgun’s SPF value is
v=spf1 include:mailgun.org ~all. If the subdomain already has an SPF record, merge the include into it (before~allor-all) so there is still only one SPF record for that hostname. Keep the total at or under 10 DNS lookups, or SPF will error instead of passing. - Publish the DKIM record exactly as Mailgun shows it. This is a TXT record carrying your domain’s public key (starting
v=DKIM1;). If you use Automatic Sender Security instead, Mailgun gives you CNAME records that let it rotate keys for you; in that mode, manually provisioned keys you no longer use can sit in an “Unverified” state without blocking verification. - Watch the host-field trap. Some DNS panels automatically append your domain to whatever you type as the host. Typing the full
mg.yourdomain.cominto such a panel can createmg.yourdomain.com.yourdomain.com. If a record will not verify, check the fully qualified name your panel actually published before assuming Mailgun is wrong.
Do not fix the wrong thing first: do not add Mailgun MX records to a domain that already receives mail. Mailgun’s own help is explicit — MX records are only for receiving mail for the exact domain you verified in Mailgun, and adding them where mail is already set up elsewhere will break that inbound mail. Skip the MX records unless Mailgun is meant to receive mail for this subdomain.
- Add the tracking CNAME only if you want Mailgun tracking on your own domain. Without it, tracking still works on Mailgun’s domain; the CNAME only changes the link domain. This is optional, not part of verification.
- Verify in Mailgun, then wait if needed. Use Verify / Check status in Domain settings. Mailgun notes propagation can take up to 24–48 hours; if records are confirmed correct in public DNS and Mailgun still shows Unverified after 24 hours, run its manual status check again rather than re-creating records.
- Add DMARC on your root domain — once, at monitoring first. Start with
p=noneand a reporting address, so you can see Mailgun’s alignment in aggregate reports before tightening the policy. Never publish a second DMARC record for the same domain; there can only be one, and subdomains inherit the root policy unless you set a subdomain policy deliberately.
Prove it worked
Send a message through Mailgun to an address you control, open its full headers, and confirm three things: the From domain is your sending subdomain (or your root domain if you deliberately configured it that way), spf=pass for your domain, and dkim=pass for your domain. Then check Mailgun’s domain status shows Verified, and confirm the “via mailgun.org” label is gone. Finally, send a message to your own business mailbox and confirm inbound mail still arrives — that proves you did not disturb your root MX records.
Still not working? Work this ladder in order
- DKIM verifies but SPF does not. You almost certainly have two SPF records for the hostname, or a CNAME sitting on the same hostname as your TXT record (a CNAME takes precedence and hides the TXT). Merge the SPF values into one record, or move Mailgun to a fresh subdomain.
- Both records look right in your panel but Mailgun says Unverified. Query public DNS. A local DNS server, or a panel that has not actually published, is the usual cause. Wait out propagation before changing values.
- Mail verifies but lands in spam. Authentication passing is necessary, not sufficient. Check your sending volume, list quality, and content, and read your DMARC aggregate reports for alignment — a passing DKIM signature for the wrong domain does not align.
- Inbound mail stopped after setup. You added Mailgun MX records to a domain that already had mailbox MX records. Remove Mailgun’s MX records from that domain and restore the mailbox MX records; keep Mailgun on its subdomain.
Mistakes that make it worse
- Adding Mailgun MX records to your root domain and breaking your business mailbox.
- Creating a second SPF record instead of merging into the existing one.
- Copying a DKIM key from a guide or screenshot instead of your own Mailgun account.
- Changing SPF, DKIM and MX at once, then being unable to tell which change broke what.
- Tightening DMARC to
p=rejectbefore Mailgun’s alignment shows as passing in reports.
FAQ — Mailgun domain authentication, answered
Why does my mail still show “via mailgun.org” after I added the records?
That label disappears only when the sending domain is verified in Mailgun and the message passes authentication for that domain. Check Mailgun’s domain status first: if it still shows Unverified, one record is missing, mistyped, or not yet visible in public DNS. Re-check each record with a public DNS query, not only your DNS panel’s saved view.
Should I add Mailgun’s records to my root domain or a subdomain?
Use a dedicated sending subdomain such as mg.yourdomain.com. Mailgun itself recommends a subdomain as its standard pattern, and it keeps Mailgun’s MX records away from your business mailbox MX records. Adding Mailgun MX records to a domain that already receives mail elsewhere will break that inbound mail.
I already have an SPF record. Do I add a second one for Mailgun?
No. There can only be one SPF record per hostname. Merge Mailgun’s include into your existing record, before the final qualifier: for example, v=spf1 include:mailgun.org ~all becomes part of your existing value, not a second TXT record.
Sources
Mailgun Help Center — DNS frequently asked questions (SPF value, one-SPF-record rule, 10-lookup limit, MX warning, 24–48 hour propagation, subdomain recommendation, Automatic Sender Security behaviour). Record values for your own domain always come from your Mailgun account’s Domain settings, not from this guide.
Did this fix work for you?
Your reaction is stored only in your own browser — it is not sent to us.