Mail setup

SPF, DKIM and DMARC with Mailgun.

The records Mailgun needs, where to find them, and the failure specific to this provider.

SPF

Add include:mailgun.org to your existing SPF record. Do not create a second record: two SPF records mean neither works, and that is the most common mistake in this whole area.

A complete record with Mailgun alone looks like v=spf1 include:mailgun.org ~all. If you use other sending tools, their includes go in the same record.

DKIM

Found in Mailgun dashboard, under Sending, then Domains.

Mailgun is a sending service rather than a mailbox provider, so it usually runs on a subdomain like mg.yourdomain.com with its own SPF and DKIM records.

Mailgun publishes keys under the selector a selector you choose, commonly mg or krs, which is what an external check looks for.

DMARC

DMARC is the same regardless of provider, because it is your instruction rather than theirs. Start at v=DMARC1; p=none; rua=mailto:you@yourdomain.com, read the reports for a few weeks, authorise everything legitimate, and only then tighten. The DMARC guide covers the order in detail, and the order is what stops you blocking your own invoices.

Worth knowing with Mailgun

Running transactional mail on a subdomain is the right pattern and it is worth copying. The subdomain gets its own SPF budget of ten lookups, and a deliverability problem on marketing mail does not affect your ordinary correspondence.

Check it afterwards

Publishing the records is not the same as them working. Verify from outside: whether SPF passes, whether a DKIM signature is actually present, and how many lookups your SPF now performs. The free mail check answers all three in plain language.

Related

Check yours

Check whether your mail is actually passing.

Plain answers rather than policy strings. Free, no account.

Using a different mail provider?

The records differ per provider, and so do the mistakes.

Klaviyo · Namecheap Private Email · Brevo · IONOS Mail · SendGrid · Salesforce and Marketing Cloud

All 20 in this set