Learn
SPF vs DKIM vs DMARC: what each does and how they work together
SPF vs DKIM vs DMARC: SPF authorizes servers, DKIM signs messages, DMARC checks the From domain. See how they differ and where each one fails.
In short
SPF vs DKIM vs DMARC is a question of three different jobs: SPF authorizes the sending server, DKIM signs the message and DMARC checks that the domain behind one of those results matches the From address.
SPF and DKIM each give a result for their own domain. DMARC compares that domain with the From address, the sender people see, and says what you want done when none matches.
| SPF | DKIM | DMARC | |
|---|---|---|---|
| Domain it checks | MAIL FROM and the HELO name |
d= in the DKIM-Signature header |
From: header |
| Where it lives in DNS | example.com |
selector._domainkey.example.com |
_dmarc.example.com |
| Example | v=spf1 ip4:192.0.2.10 ~all |
v=DKIM1; k=rsa; p=MIIBIjANBg... (key shortened) |
v=DMARC1; p=none; rua=mailto:dmarc@example.com |
MAIL FROM, the envelope sender, is the bounce address used during delivery. Mail clients do not show it as the sender, so a message can pass SPF with someone else's address in From.
How they differ
SPF vs DKIM
SPF tests the IP address of the connecting server, so the route matters. When a forwarder keeps the original MAIL FROM, SPF usually fails, because the receiver now sees the forwarder's IP. DKIM travels inside the message as a signature. A forwarder that leaves the body and signed headers alone is likely to keep it valid. A mailing list that tags the subject or adds a footer can break it.
DKIM vs DMARC
DKIM signs with a private key whose public half sits in DNS. DMARC signs nothing and holds no key. It reads the DKIM result and adds one condition: the d= domain has to align with the From domain. Aligned means identical or, in the default relaxed mode, under the same organizational domain, so d=example.com aligns with mail from news.example.com. RFC 9989 requires this because a valid signature can come from any domain, even a forger's.
SPF vs DMARC
SPF never compares anything with the From address. DMARC counts only its MAIL FROM result, and only when that domain aligns with the From domain. A service using its own bounce domain can pass SPF there, and DMARC will not count it.
How they work together
A receiver applying DMARC works in this order, though SPF may run earlier, during the connection.
- It takes the domain in the
From:header and looks for the DMARC record that covers it. With no record, DMARC does not apply. - It runs SPF and DKIM, if it has not done so already, and keeps each domain that passed.
- It compares those domains with the From domain. One aligned pass is enough for DMARC to pass.
- When DMARC fails, the receiver applies its own local policy, which may take your
p=value into account.p=nonemust not change how it already handles the message. - Receivers that send reports include the result in aggregate reports to your
rua=address.
SPF, DKIM and DMARC explained with four messages
| Message | SPF | DKIM | DMARC |
|---|---|---|---|
Your server, with your domain in MAIL FROM and d= |
Pass, aligned | Pass, aligned | Pass |
| A service with its own bounce domain, signing with yours | Pass, not aligned | Pass, aligned | Pass |
Forwarded unchanged, with the original MAIL FROM |
Usually fails | Usually passes, aligned | Passes when DKIM holds |
| A service using only its own domain | Pass, not aligned | Pass, not aligned | Fail |
To DMARC, that last row looks like a forged message. Any domain owner can publish SPF or sign for its own domain, so a pass proves nothing about the From domain until it aligns.
Common mistakes
- Reading an SPF or DKIM pass as a DMARC pass. Check the domain behind each result. Where a service allows it, have it sign with your domain. Caution: publish the records it asks for first.
- Publishing two SPF records. The check returns
permerror. Caution: merge them into one and keep every sender, or mail from the one you drop fails SPF. - Going straight to
p=quarantineorp=reject. Both can stop legitimate mail. Caution: set up DMARC atp=nonewithrua=first, the usual start RFC 9989 describes. RFC 9989 requires you to fix every legitimate source before you enforce. Forwarded mail usually fails SPF, so the RFC says domains atp=rejectmust also sign with DKIM. - Expecting DMARC to rescue an SPF
-allfailure. RFC 9989 warns that a hard fail can cause rejection before DMARC runs, even for mail with aligned DKIM. Those messages never reach aggregate reports. Caution: list every sender in SPF before-all; forwarded mail can still be rejected.