SPF, DKIM and DMARC explained, with examples

Three DNS records decide whether other mail servers trust your email. This guide shows what each one does, how to write it and how to roll them out without losing real mail.

Email8 min readUpdated 26 Oct 2026

What each record does

RecordQuestion it answers
SPFIs this server allowed to send mail for this domain?
DKIMWas this message signed by the domain, and is it unchanged?
DMARCWhat should happen if SPF and DKIM do not line up, and where do reports go?

SPF: who may send

One TXT record at the domain apex. List your sending servers and services, then end with a policy.

example.com.  TXT  "v=spf1 ip4:203.0.113.10 include:_spf.mailprovider.example -all"

-all means reject everything not listed. ~all means soft-fail, which is common while you are still finding senders.

Only one SPF record per domain. Two records make SPF fail. Merge them into one.

DKIM: a signature on every message

Your mail server signs messages with a private key. You publish the matching public key in DNS under a selector name.

sel1._domainkey.example.com.  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkqh..."

Your mail provider tells you the selector and the value. Publish exactly what they give you.

DMARC: the policy and the reports

Publish at _dmarc. Start with monitoring only, so you can see who sends as your domain.

_dmarc.example.com.  TXT  "v=DMARC1; p=none; rua=mailto:[email protected]"

Read the reports for a few weeks. When all legitimate senders pass, move to p=quarantine, then p=reject.

Check your records

With dig:

dig +short TXT example.com
dig +short TXT _dmarc.example.com
dig +short TXT sel1._domainkey.example.com

Then send a test message to a mailbox you control and read the original headers. Look for Authentication-Results with spf=pass, dkim=pass and dmarc=pass.

Common mistakes

  • Two SPF records instead of one merged record
  • More than ten DNS lookups in SPF (too many include entries)
  • Forgetting a sender such as a newsletter or invoicing tool
  • Jumping straight to p=reject without reading reports
  • Publishing a DKIM key with a line break or missing characters

Questions

Do I need all three?

Yes. Large mailbox providers now expect SPF and DKIM, and DMARC tells them what to do with mail that fails.

Why does my mail still go to spam?

Authentication is necessary but not sufficient. Sending reputation, content and list quality matter too.

Want this done for you? See our Email and DNS service: DNS, SPF, DKIM, DMARC and mail servers set up so your email arrives.

Want this done for you?

We set up and check all of this on client servers, with a backup first and a written record.