Guide ยท 9 min read

SPF, DKIM and DMARC Explained

How these three DNS records work together to stop email spoofing, with real record examples and the mistakes that quietly break them.

The Problem These Records Solve

Email's original protocol (SMTP) has no built-in way to verify that a message actually came from who it claims to be from โ€” the "From" address is just a text field a sender can set to anything. This is why email spoofing and phishing have historically been so easy. SPF, DKIM and DMARC are three DNS-based standards that, used together, let receiving mail servers verify a message's authenticity and decide what to do with messages that fail.

SPF: Sender Policy Framework

SPF is a DNS TXT record published on your domain that lists which mail servers are authorized to send email on its behalf. A receiving server checks the sending server's IP against this list.

v=spf1 ip4:203.0.113.10 include:_spf.google.com -all
  • v=spf1 โ€” declares this a valid SPF record (there must be exactly one per domain)
  • ip4: / ip6: โ€” authorizes a specific IP address
  • include: โ€” authorizes another domain's SPF-listed senders (common for services like Google Workspace or Microsoft 365)
  • -all โ€” hard fail: reject anything not explicitly listed. ~all is a soft fail (mark as suspicious but don't outright reject); +all effectively disables SPF and should never be used.

SPF has a hard limit of 10 DNS lookups per check (each include, a, mx and similar mechanism counts). Exceeding it causes the SPF check to fail entirely โ€” a surprisingly common misconfiguration when several third-party services are chained together with include statements.

DKIM: DomainKeys Identified Mail

DKIM works differently: instead of checking the sending IP, it adds a cryptographic signature to each outgoing message's headers. The corresponding public key is published in DNS at a location identified by a selector โ€” a short string chosen by the sending service, forming a record at selector._domainkey.yourdomain.com.

Record location: selector1._domainkey.example.com Record type: TXT Record value: v=DKIM1; k=rsa; p=MIGfMA0GCSq...(public key)

The receiving server fetches this public key from DNS and verifies the signature against the message content. If the signature validates, it proves two things: the message really was signed by a server holding the matching private key, and the signed parts of the message weren't altered in transit.

DMARC: Domain-based Message Authentication, Reporting and Conformance

DMARC ties SPF and DKIM together and tells receiving servers what to do when a message fails both. It's published as a TXT record at _dmarc.yourdomain.com:

v=DMARC1; p=quarantine; rua=mailto:reports@example.com; pct=100
  • p= โ€” the policy: none (monitor only, take no action), quarantine (send to spam), or reject (refuse the message outright)
  • rua= โ€” an address to receive aggregate daily/weekly reports showing which servers are sending mail as your domain and whether they pass authentication
  • DMARC also requires alignment โ€” the domain in SPF or DKIM must match the visible "From" domain, not just pass in isolation

The standard rollout path is p=none first (collect reports, confirm all legitimate senders pass), then move to p=quarantine, then p=reject once confident nothing legitimate will be blocked.

How They Work Together: A Mail Flow Walkthrough

When a message arrives, the receiving server: (1) checks SPF by comparing the sending IP against the domain's SPF record, (2) checks DKIM by verifying the cryptographic signature against the published public key, (3) checks DMARC alignment โ€” do the SPF and/or DKIM domains match the visible From address โ€” then (4) applies the DMARC policy based on the combined result. A message can pass SPF but fail DMARC alignment if the SPF-passing domain doesn't match the From address, which is a common source of confusion when troubleshooting.

Common Mistakes

  • Publishing two SPF TXT records instead of merging into one โ€” this makes SPF invalid, not just redundant.
  • Exceeding the 10 DNS lookup limit by chaining too many include: mechanisms.
  • No DMARC record at all โ€” SPF and DKIM alone don't tell receiving servers what to do on failure, leaving spoofed mail handling entirely up to the receiver's own judgment.
  • Jumping straight to p=reject without first monitoring via p=none and reviewing reports โ€” this can silently block legitimate mail from a forgotten sending service.

Check your own records for syntax problems with the SPF / DKIM / DMARC Checker before rolling out changes.

Tools For This Guide

Frequently Asked Questions

Do I need all three โ€” SPF, DKIM and DMARC?
For meaningful protection, yes. SPF and DKIM each verify different things and both have gaps if used alone. DMARC is what actually instructs receiving servers what to do on failure and ties the other two together with alignment checks โ€” without it, spoofing protection is inconsistent across different mail providers.
Why did my SPF record stop working after adding another service?
SPF allows a maximum of 10 DNS lookups during evaluation. Each include:, a, mx, ptr and similar mechanism counts toward that limit. Adding one too many third-party include: statements can push you over the limit, causing the entire SPF check to fail (a permerror).
What does DMARC alignment mean?
Alignment means the domain that passed SPF or DKIM must match (or be a subdomain of) the domain shown in the message's visible From address. A message can pass SPF in isolation but still fail DMARC if the passing domain doesn't align with the From header.
Should I start with p=reject in my DMARC record?
No โ€” start with p=none to collect aggregate reports and confirm every legitimate sending service passes authentication, then move to p=quarantine, then p=reject. Jumping straight to reject risks silently blocking legitimate mail you didn't know was still using an old sending path.

Check Your Own SPF, DKIM and DMARC Records

Validate record syntax, SPF lookup counts and common mistakes before publishing changes to production DNS.