Mailgun sends application mail over its API or SMTP. To send that mail as your domain and pass DMARC, publish the records below and check the alignment notes.
What to add.
include:mailgun.org in the SPF record of the domain Mailgun sends
from, plus the DKIM records Mailgun shows for it. Send from a subdomain such as
mg.example.com. Add Mailgun's MX records only on a domain whose incoming mail
should go to Mailgun. If another provider receives that domain's mail, keep its MX records and
leave Mailgun's out. Your root SPF record needs the include only if Mailgun sends from your
root domain.
What signs your mail. DKIM records Mailgun generates for your account.
If you point a domain's MX records at Mailgun, its mail goes to Mailgun instead of your current provider. Delete Mailgun's MX records to undo it.
The SPF record
Put this on the domain Mailgun sends from, and make that a subdomain such as
mg.example.com. Add Mailgun's MX records there unless another provider receives
mail there.
The include is:
Count your lookups after any change, because SPF allows ten DNS lookups across the whole chain of includes. A sender that receivers need an eleventh lookup to find gets a permerror and fails SPF. Our free SPF checker follows every include and gives you the count. It also shows whether Mailgun needs the include on the domain you check.
DKIM
Mailgun shows its DKIM record in the domain's DNS records panel: a TXT record, or two CNAME
records with Automatic Sender Security on. The selector varies, so read it off the panel. The
record goes under the domain Mailgun sends from, such as mg.example.com.
Return path and SPF alignment
Mailgun tracks delayed bounces only if the sending domain's MX records point to it. On a subdomain that receives no other mail, add them:
An EU domain uses mxa.eu.mailgun.org and mxb.eu.mailgun.org
instead.
Because Mailgun's bounce address is on mg.example.com, an SPF pass there
counts for a From address at example.com.
DMARC alignment with Mailgun
DMARC passes when SPF or DKIM passes and the domain it authenticated matches the domain in your visible From address. A provider can pass both checks for its own domain while your mail fails DMARC.
- Mailgun needs a CNAME on the sending domain to track clicks, opens and unsubscribes. DMARC doesn't use it.
- Mailgun's EU and US regions use different records. An EU domain's tracking CNAME points
at
eu.mailgun.org. - Sending from the root domain works and costs you the ability to keep the two reputations apart. Use the subdomain.
The DMARC alignment guide covers the general case, and the dmarc=fail page shows how to read the Authentication-Results header.
Verification
Substitute your domain, and run these after the TTL on anything you replaced has expired:
Then send one message through Mailgun to a Gmail address you control, open Show original,
and look for dkim=pass with your domain in header.i. A test
message shows what a receiver does with your mail. A DNS lookup only shows what you
published.
Our SPF checker gives you the lookup count. The DKIM checker shows whether a selector resolves and whether the key is long enough, and the DMARC checker reads your policy back to you. You can use them free, without an account.
I checked the values here against Mailgun's own documentation, at Mailgun documentation. Providers change their DNS requirements without much notice. If their screen shows something different from this page, follow their screen and tell us.
A record can be correct and still fail alignment once real mail goes through it. Receivers record that result in the reports they send. We read the reports for you, and on a paid plan we email you the day a new sender fails. See whether this sender passes. Your first domain is free.
Does your domain need Mailgun's SPF include?
We look for include:mailgun.org in your SPF record, say whether Mailgun
needs it there, and count your lookups.
Free · No signup · The result names what to change
Keep reading
Adding this to a domain that already sends? Our SPF record generator merges the include into the record you publish today rather than replacing it, the SPF checker resolves every include and counts the lookups, and the DKIM checker confirms the selector answers.