SPF, DKIM and DMARC for Mailgun

Short answer: Mailgun mail passes Gmail, Yahoo and Microsoft checks when you turn on DKIM with your own domain, add include:mailgun.org to your one SPF record and publish a DMARC record at _dmarc (start with p=none). The exact records and clicks are below.

SPFTXT at @
v=spf1 include:mailgun.org ~all
Put it on the domain you send from in Mailgun. Mailgun suggests a subdomain such as mg.yourdomain.com when your main domain already runs your company mail; then this record goes at mg, not at @. Combine with your other senders →
DKIMCNAME / TXTTXT record at <selector>._domainkey of your sending domain, with the key from Mailgun's Domain Verification & DNS page. The selector differs per account (krs, smtp, pic, k1…).
DMARCTXT at _dmarc
v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com
Start with p=none and a mailbox you read, or a free report address that turns the reports into a dashboard; build your own.

Step by step

  1. In the Mailgun control panel add your sending domain (e.g. mg.yourdomain.com) and pick the US or EU region.
  2. Add the two TXT records it lists: SPF (v=spf1 include:mailgun.org ~all) and DKIM.
  3. Want Mailgun to receive replies or route mail? Add MX mxa.mailgun.org and mxb.mailgun.org (priority 10) on the sending domain.
  4. For open and click tracking add the CNAME (usually email) pointing to mailgun.org (eu.mailgun.org for EU domains).
  5. Click Check DNS Records Now. Verification can take 24–48 hours.
  6. Publish DMARC at _dmarc of your main domain with p=none; it covers subdomains too.

Mistakes that break it

Check that it worked

After the fix, keep an eye on it: free DMARC monitoring shows every service that sends mail as your domain and which ones fail, in plain English.

Rather not touch DNS? I set up SPF, DKIM and DMARC without breaking your other senders, with a before/after report.

Get it fixed on Fiverr

Prefer to do it yourself? Get the step-by-step Fix Kit ($15) – 19-page guide, checklist, 20+ providers.

Other setup guides

Google Workspace · Microsoft 365 · Zoho Mail · Hostinger Email · Titan Email · GoDaddy email (Microsoft 365 and Professional Email) · Proton Mail · Cloudflare Email Routing · Mailchimp · SendGrid · Amazon SES · Shopify Email · Klaviyo · HubSpot · Brevo · Postmark · Zendesk · Constant Contact · MailerLite · Kit (ConvertKit)