This guide shows the DNS records Mailgun needs so your email is authenticated: SPF, DKIM and DMARC. Use the exact values from your Mailgun account where they differ — providers update them from time to time.
1. SPF record for Mailgun
include:mailgun.org
Mailgun is usually set up on a sending subdomain such as mg.yourdomain.com. Add the SPF TXT record shown by Mailgun on that subdomain.
Use the SPF Generator to combine several services and the SPF Checker to confirm you stay under 10 DNS lookups.
2. DKIM for Mailgun
In Mailgun, follow this path and publish the record it shows:
- Mailgun → Sending → Domains → your domain → DNS records → add the DKIM TXT record (the selector name is shown there) plus the SPF, MX and tracking CNAME records
- Verify DNS settings.
- Give DNS a few minutes, then confirm the record with the DKIM Checker.
Once published, verify it with the DKIM Checker (it can also discover common selectors).
3. DMARC
After SPF and DKIM pass, add a DMARC record so receivers know your policy and send you reports. Start in monitoring mode:
v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com
Then follow the step-by-step DMARC rollout to reach quarantine and reject safely.
Where to add the records
- Cloudflare — Cloudflare dashboard → select your domain → DNS → Records → Add record. For mail records keep the proxy (orange cloud) OFF.
- GoDaddy — GoDaddy → My Products → your domain → DNS → Manage DNS → Add New Record.
- Namecheap — Namecheap → Domain List → Manage → Advanced DNS → Add New Record. Use "@" for the root domain.
- Hostinger — Hostinger hPanel → Domains → your domain → DNS / Nameservers → Manage DNS records.
- Amazon Route 53 — AWS console → Route 53 → Hosted zones → your domain → Create record. Wrap TXT values in quotes.
Frequently asked questions
Do I need SPF, DKIM and DMARC for Mailgun?
Yes. Gmail and Yahoo require SPF and DKIM plus DMARC for bulk senders, and authenticated mail is far less likely to land in spam.
Can I have two SPF records?
No. Two SPF records make SPF fail. Combine all services into one record.
How do I check that Mailgun authentication works?
Run the Domain Checker, or send a message to Gmail and use "Show original" to see SPF, DKIM and DMARC results.