ESP
SPF, DKIM & DMARC for Mailgun
Everything Mailgun needs to send authenticated mail as your domain: the SPF include, the DKIM setup, and the DMARC record that ties it together, in the correct order.
Mailgun authentication specification
| Record | Value for Mailgun | Notes |
|---|---|---|
| SPF include | include:mailgun.org | Costs one of the 10 allowed DNS lookups |
| DKIM selector | smtp | Verify with the DKIM checker after setup |
| DMARC location | _dmarc.yourdomain.com | One record covers every sender, Mailgun included |
| DNS record types | CNAME and/or TXT as the steps state | Keep mail records unproxied (DNS only) |
Mailgun gotcha: Mailgun has two modes: mg.yourdomain.com subdomain (recommended, keeps tracking separate) or bare root domain; records differ between them.
Step 1: Verify your domain in Mailgun
Before any records, Mailgun must recognize your domain. In Mailgun's settings, find Sending domains / Sender authentication / Verified domains, add your domain, and complete whatever verification it asks for (usually a TXT token or a dashboard confirmation). Records you publish before this step often don't activate.
Step 2: Add Mailgun to your SPF record
Add include:mailgun.org as a mechanism to your existing SPF record. On a typical domain the record then looks like:
v=spf1 include:_spf.google.com include:mailgun.org ~all
Rules that matter: your domain has exactly one SPF record (two = permerror),
and every include: costs one of the
10 allowed DNS lookups.
If you're stacking several services, run the
SPF checker after this step;
if the meter is near 10, the SPF flattener fixes it free.
Step 3: Publish Mailgun's DKIM key
In Mailgun's domain/authentication settings, generate the DKIM key. Mailgun shows you a DNS record to create:
- Type CNAME or TXT, exactly as their dialog states.
- Host/name:
smtp._domainkey. - Value: the long key string. Paste it verbatim; no added quotes or spaces.
Once the record propagates (minutes), click the verify/generate button in Mailgun so the service starts actually signing mail. Publishing DNS without triggering the signer is the classic half-done setup. Confirm the key is live with the DKIM checker.
Step 4: Publish (or update) DMARC
Create a TXT record at _dmarc.yourdomain.com. Starting value, with your address
in the reporting tag:
v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com
With Mailgun now passing SPF and DKIM, your aggregate reports will show aligned passes. After a clean reporting cycle, step the policy up to quarantine, then reject, using the roadmap in the DMARC guide. Build the record with the DMARC generator, verify with the DMARC checker.
Step 5: Verify the whole stack
Send a test message from Mailgun to yourself, then open its
Show original / View source and check the
Authentication-Results line: SPF pass, DKIM pass, DMARC pass. Or scan everything
at once with the homepage security scanner.
Frequently asked questions
Does Mailgun need its own DMARC record?+
No. DMARC is published once for your domain and covers every legitimate sender, including this service. The service just needs SPF and DKIM set up so DMARC sees aligned passes.
Where do I find the exact DNS values for Mailgun?+
In the service's own domain-authentication settings page. Providers rotate infrastructure, so the in-app values always beat tutorials. This guide gives the process and the known values.
Can I use this domain with multiple sending services?+
Yes: each service adds its own include (or CNAMEs) and DKIM selector. Watch the SPF 10-lookup limit as senders stack, and flatten if you approach it.
How long until Mailgun DNS changes take effect?+
The DNS records verify within minutes to an hour, but receiver-side caches obey the old record's TTL. Check worldwide agreement with the propagation checker before your first campaign.
Why do my Mailgun emails still go to spam after authentication?+
Authentication is necessary but not sufficient: sender reputation, list quality, warm-up, and content also score your mail. Verify SPF, DKIM, and DMARC all pass first, then address engagement factors.
Do I need a separate SPF record for Mailgun?+
Never. A domain has exactly one SPF record; adding a second one breaks both. Instead, add the service's include mechanism to your existing record.
Should I send Mailgun mail from a subdomain instead?+
Often yes: a dedicated subdomain (mail.yourdomain.com) isolates campaign reputation from your corporate mail and only needs its own records. Both approaches support full authentication.
How do I confirm Mailgun's DKIM is actually working?+
Send a test message and read the Authentication-Results header for dkim=pass, or run the selector through the DKIM checker to confirm the key is live in DNS.
Verify your setup
Related guides
Last verified: 2026-09-06