SPF, DKIM, and DMARC: reading records and moving to enforcement
What each email authentication record proves, how to read SPF, DKIM, and DMARC with dig, why alignment matters, and a staged path from p=none to p=reject using aggregate reports.
Diagram
Checking a domain’s mail authentication
Step 1 of 4
SPF
Which servers may send for the envelope domain.
$ dig +short TXT example.test "v=spf1 include:_spf.mailhost.example ip4:198.51.100.0/24 -all"
The example on the open step is one illustration, or the fix you can paste into an application you own.
What this page is made of
3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.
SPF limits
- What fails
- SPF checks the envelope sender and allows at most ten DNS lookups.
- Who is affected
- Recipients, when records break silently and mail fails or spoofing passes.
- What you would notice
- Nested includes that exceed ten lookups, or ~all left forever.
- What you change
- Flatten includes you control and end with -all once senders are known.
DKIM keys
- What fails
- Each sending service signs with its own selector and key.
- Who is affected
- Recipients trusting signatures from forgotten or weak keys.
- What you would notice
- 1024-bit keys or selectors for services you no longer use.
- What you change
- Use 2048-bit keys, rotate them, and remove old selectors.
DMARC enforcement
- What fails
- Without p=quarantine or p=reject, receivers are told to deliver spoofed mail anyway.
- Who is affected
- Customers and staff who receive mail that appears to come from your domain.
- What you would notice
- p=none for years with nobody reading reports.
- What you change
- Read aggregate reports, fix legitimate senders, then raise the policy.
Reading a received message
The Authentication-Results header shows what the receiving server concluded. Check SPF, DKIM, and DMARC results and which domains they were evaluated for.
Authentication-Results: mx.recipient.example; spf=pass smtp.mailfrom=bounce.mailhost.example; dkim=pass header.d=example.test header.s=s1; dmarc=pass (p=QUARANTINE) header.from=example.test
Using aggregate reports
DMARC aggregate (rua) reports are XML files from receivers listing source IPs and results. Feed them to a parser or a DMARC reporting service, list every source sending as your domain, and decide for each: authorize it, fix its alignment, or block it.
Bulk sender requirements
Since 2024, large mailbox providers require bulk senders to publish DMARC, align SPF or DKIM, and support one-click unsubscribe. Even small senders benefit from meeting the same bar.
Check yourself
Recognition and the fix. Nothing here is a procedure.
SPF and DKIM pass, but for a vendor’s domain rather than the From domain. What does DMARC say?
Go deeper
Specific techniques, exercises, and glossary cards for this topic.
Exercises
- 01Phishing header analyzerParse three real-shaped message headers, follow the Received hops, and work out why SPF, DKIM, and DMARC pass or fail for each one.
- 02Terminal mission: An SPF include for a vendor that no longer existsWalk a domain’s SPF record with dig, resolve every include, and find the one pointing at a domain that no longer resolves and could be registered by anyone.
- 03Lookalike domain triageNew registrations that resemble your brand: decode punycode, name the trick each one uses, and decide which are ready to send phishing mail.
- 04Terminal mission: The same thread, a different domainAn invoice thread changes bank details halfway through. Compare sender domains character by character, follow In-Reply-To, and find the lookalike that slipped into the conversation.