SPF, DKIM and DMARC Explained

These three DNS records prove that email claiming to come from your domain really does. Without them, your messages are more likely to land in spam, and anyone can impersonate you.

SPF, DKIM and DMARC Explained — Troiana insight cover

In short

SPF lists the servers allowed to send your email. DKIM adds a cryptographic signature proving a message hasn't been altered. DMARC tells receivers what to do when those checks fail, and sends you reports. Set up all three, starting DMARC at p=none, then move to quarantine and reject once all your legitimate senders pass. Gmail, Yahoo and Outlook expect them, particularly from bulk senders.

The three records

Email was designed without authentication, so anyone can put your domain in the From line. These standards help receivers work out what's genuine.

RecordQuestion it answersHow
SPFIs this server allowed to send for this domain?A DNS list of allowed senders
DKIMWas this message signed by the domain, and unaltered?A signature checked against a public key in DNS
DMARCWhat should happen if those checks fail?A DNS policy, with reporting

If mail isn't arriving, read why your emails go to spam as well. Authentication is necessary, but it isn't sufficient on its own.

SPF

SPF is a TXT record on your domain:

example.com. TXT "v=spf1 include:_spf.google.com include:sendgrid.net ~all"
  • include: adds a provider's list of servers.
  • ~all soft-fails everything else. -all is a stricter hard fail.

Things to know:

  • You can only have one SPF record per domain. Merge entries, rather than adding a second one.
  • There's a limit of 10 DNS lookups. Too many include statements can break SPF, with a “permerror”.
  • It checks the hidden return-path address, not the visible From address. That's one reason DMARC exists.
  • It often breaks on forwarding.

DKIM

Your email provider signs each message with a private key, and publishes the public key in DNS. Providers usually give you a record to add:

selector1._domainkey.example.com. CNAME selector1.dkim.provider.example.

Some use a TXT record containing the key itself. The “selector” allows several keys, so each sending service can have its own.

Things to know:

  • Turn it on in each service. Adding a DNS record alone may not be enough.
  • Use 2048-bit keys where your provider offers them.
  • DKIM survives forwarding better than SPF, because the signature travels with the message.

DMARC

DMARC ties it together by checking that SPF or DKIM passes and that the passing domain matches the visible From address. This is called alignment.

_dmarc.example.com. TXT "v=DMARC1; p=none; rua=mailto:dmarc@example.com"
  • p=none: monitor only, take no action.
  • p=quarantine: treat failures as suspicious, usually sending them to spam.
  • p=reject: refuse failures.
  • rua: where aggregate reports get sent.

The important point is that DMARC only needs one of SPF or DKIM to pass and align. Since SPF is fragile, make sure that DKIM is aligned for every service you use.

The safe rollout order

Jumping straight to p=reject can block your own invoices. Do it in stages:

  1. List everything that sends as your domain. Your mailbox provider, marketing tool, CRM, invoicing, support desk and website forms. People usually find more than they expect.
  2. Set up SPF.
  3. Enable DKIM on every service.
  4. Publish DMARC at p=none, with a reports address.
  5. Read the reports for two to four weeks. They arrive as XML, so a free or paid DMARC analysis tool is helpful.
  6. Fix any legitimate senders that fail.
  7. Move to p=quarantine, optionally using pct= on a staged basis if your provider recommends it.
  8. Move to p=reject, once you're confident.

DNS changes can take a while to spread. See how DNS works and what a CNAME record is.

Moving to enforcement
List sendersEverything using your domain
SPF and DKIMOn every service
p=noneRead reports for 2–4 weeks
p=quarantineOnce legitimate mail passes
p=rejectThe end state
Jumping straight to p=reject can block your own invoices. The reports are how you find the senders you forgot.

What mailbox providers expect

Guides to the current rules report that Google and Microsoft apply bulk requirements at around 5,000 messages a day. Yahoo publishes no fixed number, and all three expect SPF, DKIM and aligned DMARC. Check each provider's own documentation for the current wording.

For bulk marketing mail, Google and Yahoo also expect a one-click unsubscribe. Even if you send far fewer messages, setting these up is good practice, as they improve deliverability and protect your name.

One point that several sources make: p=none meets the minimum but doesn't stop anyone from spoofing you. To get real protection, you need to move on to enforcement.

Common problems

SymptomLikely cause
SPF permerrorTwo SPF records, or too many lookups
DKIM fails for one serviceSigning not enabled, or a wrong selector
SPF and DKIM pass, but DMARC failsAlignment: they pass for a different domain
Forwarded mail failsForwarding broke SPF; check that DKIM aligns
Contact form email goes to spamThe website is sending as your domain without authorisation
A subdomain gets spoofedAdd a subdomain policy with sp=

To check any message, open it in Gmail and choose “Show original”, where you'll see SPF, DKIM and DMARC results.

Use subdomains for different kinds of mail

Send marketing from something like news.example.com, and transactional email from mail.example.com. A problem with one stream then has less effect on the other, particularly your important invoices and password resets. See cheaper SendGrid alternatives for sending tools.

Also protect domains that don't send email

Parked domains can be spoofed too. Publish a simple “send nothing” policy:

example.net. TXT "v=spf1 -all"
_dmarc.example.net. TXT "v=DMARC1; p=reject"

What this doesn't do

These standards don't stop lookalike domains, such as your name with a small typo. They don't guarantee the inbox either, since content, reputation and engagement all matter. And they don't protect against someone who gets into a real mailbox, which is why you should also turn on two-factor authentication.

If you'd like help getting your domain's email set up correctly, book a call.

Common questions

Do I need SPF, DKIM and DMARC?

Yes, if you send email from your domain. Major mailbox providers expect them, especially for bulk senders, and they reduce spoofing and improve deliverability. Set up all three, even at low volume, because the work is small compared with the benefit.

What's the difference between SPF and DKIM?

SPF lists which servers may send for your domain. DKIM adds a signature that proves that a message came from your domain and wasn't changed. DKIM survives forwarding better. DMARC then checks that at least one aligns with your visible From address.

What DMARC policy should I use?

Start with p=none, to gather reports without affecting delivery. Fix any legitimate senders that fail, then move to p=quarantine and finally to p=reject. p=none meets minimum rules but doesn't stop spoofing, so don't stay there indefinitely.

Why does DMARC fail when SPF and DKIM pass?

Usually because of alignment. Those checks may pass for a provider's domain instead of your From domain. Configure your sending service to use your own domain for DKIM signing, or for its return path, so the domains match.

Have something worth building right?