Skip to content

SPF, DKIM and DMARC explained

Engineering5 min read

What SPF, DKIM and DMARC each do, the failure modes that break them, and how to read an Email Authentication Check result so you know what to fix first.

Three records, one job

Email was designed without a way to prove who sent a message, so anyone can write any address in the From line. SPF, DKIM and DMARC are DNS-based checks that add that proof. Receiving servers read them and decide whether a message is genuine, suspicious or forged.

Each record answers a different question. SPF asks whether the sending server is allowed to send for the domain. DKIM asks whether the message carries a valid signature from that domain. DMARC asks whether the passing check matches the domain people see in the From line, and tells receivers what to do when it does not.

SPF: who may send

SPF is a TXT record that starts with v=spf1. It lists the servers and services allowed to send for a domain, for example v=spf1 include:_spf.mail.northwind.example -all. The ending says what to do with everything else: -all means fail, and ~all means soft fail.

The receiver checks the connecting server against the record of the envelope sender domain, the address used for bounces. Two limits catch people. A domain should publish only one SPF record, and evaluation may use at most 10 DNS lookups. Mechanisms such as include, a, mx, ptr and exists, and the redirect modifier, count toward the limit, including those nested inside an include. Mechanisms such as ip4 and ip6 do not.

Pay attention to the ending too. A record that ends in +all authorizes every server on the internet, and one that ends in ?all says nothing about the rest. Subdomains that send mail need their own record, and SPF often fails on forwarded mail, because the forwarding server is not in your list.

DKIM: a signature on every message

With DKIM, your sending service signs each message with a private key. The matching public key sits in DNS at a name made of a selector, the label _domainkey and your domain, such as s1._domainkey.northwind.example. The selector is named in the signature header, so a receiver knows where to look.

A valid signature shows that the message was signed by someone who controls that domain's DNS and that the signed parts were not changed on the way. Because the signature travels with the message, it usually survives forwarding, which is where SPF often fails.

Keys need maintenance. Publish a key of reasonable length, commonly 2048 bits, rotate it on a schedule, and keep the old record in DNS until mail signed with it has stopped flowing. A domain can hold several selectors at once, which is how you run more than one sending service without conflicts.

DMARC: alignment and policy

DMARC is a TXT record at _dmarc under your domain, for example v=DMARC1; p=none; rua=mailto:dmarc@northwind.example. A message passes DMARC when SPF or DKIM passes and the domain that passed matches the visible From domain. The p tag sets the policy for failures: none, quarantine or reject.

The rua tag names where aggregate reports go. Those reports list who sent mail using your domain and whether it passed, which is how you discover forgotten sending tools and spoofing attempts.

Alignment is where third-party senders trip. A newsletter tool that signs with its own domain can pass DKIM and still fail DMARC, because the signing domain does not match your From domain. The fix is to set up custom signing so the tool signs as your domain. The record can also carry a separate policy for subdomains, which lets you tighten the main domain first.

Three failure modes that cause most problems

Most broken setups fail in one of three ways. Check for these before looking for anything exotic.

  • SPF over the 10-lookup limit. Every marketing, support and billing tool adds an include, and nested includes add more. When the total passes 10, the record returns a permanent error and many receivers treat it as a fail. Remove tools you no longer use and replace includes with ip4 ranges where the provider's addresses are stable.
  • A missing or wrong DKIM selector. The sending service gives you a selector and a record to publish, and the mail only passes when that exact name exists in DNS. Failures come from a record that was never added, a typo, a key that was rotated without updating DNS, or a service that signs with its own domain instead of yours.
  • DMARC stuck on p=none forever. A policy of none collects reports and enforces nothing, so spoofed mail is still delivered. It is the right place to start, and a poor place to stay. Read the reports, fix every legitimate sender, then move to quarantine and reject.

Reading an Email Authentication Check result

Email Authentication Check takes a sending domain and grades its MX, SPF, DKIM and DMARC setup from 0 to 100. It costs 2 credits per lookup. Start with the overall grade to see how much work there is, then read the finding for each of the four areas.

Fix problems in this order. Missing MX records mean the domain cannot receive replies or bounces. An SPF finding about too many lookups or multiple records comes next, because it can fail every message. Then look at DKIM, and last at the DMARC policy. A DMARC record at p=none will lower the grade and is a prompt to start the move to enforcement.

A result describes what is published in DNS, so it cannot see a selector it does not know about. If a service of yours signs with a custom selector and the check reports no DKIM, confirm the selector in that service's settings before you conclude that signing is off.

A sensible order of changes

Publish SPF for every service that sends your mail, turn on DKIM in each one, then publish DMARC at p=none with a reporting address. Watch the reports for a few weeks, fix every legitimate sender that fails alignment, and move to quarantine and then reject.

Recheck the domain after every change, since a new tool added by another team can break SPF without anyone noticing. Results are cached for 7 days, so pass fresh set to true when you want to see a change you just published.

[ Validate ][ Enrich ]
[Get started]

Run your first lookup in two minutes

Create a key, pick a plan and call any product in the catalog. Plans start at $29 a month.

[ Screen ][ Scrape ]