How SPF, DKIM and DMARC actually decide
Jaime Guerrero · · 6 min read
SPF, DKIM and DMARC are usually explained as three DNS records you publish. That's the easy part. What causes the real problems, mail that fails even though "all three records are there", is how a receiving server evaluates them. This is that part.
Every message has two senders
An email carries two different "from" addresses:
- The envelope sender, given in the SMTP
MAIL FROMcommand. Bounces go here, and the receiver records it asReturn-Path. People never see it. - The header From, the
From:line in the message itself. This is the one your mail app shows.
They are often different. A newsletter tool might send with an envelope sender like bounces+12345@mail.sendtool.com and a header From of news@yourdomain.com. Most of what's confusing about email authentication comes from which check looks at which address.
| Check | What it verifies | Which domain it looks at |
|---|---|---|
| SPF | The sending server's IP is allowed to send for the domain | The envelope sender (or the HELO name if the envelope sender is empty) |
| DKIM | The message was signed by a domain and hasn't been changed since | The domain in the signature's d= tag |
| DMARC | SPF or DKIM passed for the domain in the header From | The header From |
So SPF and DKIM can both pass while authenticating the newsletter tool's domain rather than yours. DMARC exists to close that gap.
How SPF is evaluated
An SPF record is a list of mechanisms read left to right. The first one that matches the connecting IP decides the result. Here is google.com's:
$ dig +short TXT google.com | grep spf1
"v=spf1 include:_spf.google.com ~all"
$ dig +short TXT _spf.google.com
"v=spf1 ip4:74.125.0.0/16 ip4:209.85.128.0/17 ip6:2001:4860:4864::/56 ip6:2404:6800:4864::/56 ip6:2607:f8b0:4864::/56 ip6:2800:3f0:4864::/56 ip6:2a00:1450:4864::/56 ip6:2c0f:fb50:4864::/56 ~all"
include: means "evaluate that other domain's record, and if it passes, this one passes". The receiver follows the include and checks the IP against the ranges there. If nothing matches, the final all applies, and its prefix sets the result:
| Prefix | Result | What receivers usually do |
|---|---|---|
+ (default) | pass | Accept |
- | fail | Strong evidence of forgery |
~ | softfail | Accept but treat as suspicious |
? | neutral | No opinion |
There are three more results. none means there's no SPF record. temperror is a temporary DNS failure. permerror means the record itself is broken: a syntax error, two v=spf1 records on the same name, or more than 10 DNS-querying mechanisms. A permerror fails every message, which is why the 10-lookup limit matters so much.
SPF has a structural weakness: it authenticates the path, not the message. When a message is forwarded, the forwarding server's IP isn't in your SPF record, so SPF fails at the final destination even though the message is genuine.
What a DKIM signature covers
DKIM signs the message itself, so it survives forwarding as long as nothing is modified. The sending server adds a DKIM-Signature header with these key tags:
| Tag | Meaning |
|---|---|
d= | The signing domain, the domain taking responsibility |
s= | The selector, which tells the receiver where to find the public key |
h= | The list of headers included in the signature, for example from:to:subject:date |
bh= | A hash of the body |
b= | The signature over the listed headers and the body hash |
c= | Canonicalization, relaxed or simple: how tolerant the check is of whitespace changes |
The receiver looks up the public key at <selector>._domainkey.<d=>. Selectors exist so a domain can have several keys at once, one per sending service. github.com is a good example:
$ dig +short TXT google._domainkey.github.com
"v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAj6T5sl/RwdSqGoYWaWaFbS2UAey..."
$ dig +short TXT s1._domainkey.github.com
s1.domainkey.u51742174.wl175.sendgrid.net.
"k=rsa; t=s; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyn3fMCVpb7ryIRKOGXhXVGYmsWUitNl..."
(Keys shortened.) The google selector is GitHub's Google Workspace mail. The s1 selector is a CNAME to SendGrid, so SendGrid can rotate that key without GitHub touching its DNS. This is the usual pattern for third-party senders.
An empty key is how a selector is retired. Gmail's old selector still exists but publishes nothing:
$ dig +short TXT 20230601._domainkey.gmail.com
"v=DKIM1; k=rsa; p="
An empty p= tells receivers the key is revoked, so any signature claiming that selector fails.
DKIM breaks when something changes the signed parts after sending. Mailing lists are the classic case: they add a footer to the body or a [list] prefix to the subject, and the body hash or signature no longer matches.
Alignment: where DMARC comes in
DMARC passes when at least one of these is true:
- SPF passes and the envelope sender's domain aligns with the header From domain, or
- DKIM passes and the
d=domain aligns with the header From domain.
"Aligns" has two modes, set by aspf= and adkim= in the DMARC record:
- Relaxed (the default): the two domains share the same organizational domain.
mail.yourdomain.comaligns withyourdomain.com. - Strict: the domains must be identical.
That's why the newsletter example above fails DMARC even with SPF and DKIM passing: the authenticated domain is sendtool.com, and the header From is yourdomain.com. The fix is to have the tool sign with DKIM as your domain (usually by adding the CNAME selectors it gives you), or to send from a subdomain of yours as the envelope sender.
DKIM alignment is the one to rely on. It survives forwarding, and SPF alignment doesn't.
What changed in 2026: RFC 9989
DMARC was revised in May 2026. RFC 9989 replaces the original RFC 7489, and splits reporting into RFC 9990 and RFC 9991. The changes that matter in practice:
- The organizational domain is found by a DNS tree walk. Receivers used to work out that
mail.yourdomain.co.ukbelongs toyourdomain.co.ukusing the Public Suffix List. Now they walk up the DNS name looking for DMARC records, with at most eight lookups, and a newpsd=tag lets domain registries mark themselves as public suffixes. pct=is gone. Percentage rollouts are replaced by a test flag,t=y, which asks receivers to apply one level less than the stated policy:rejectis treated asquarantine, andquarantineasnone.np=is now standard. It sets the policy for subdomains that don't exist at all, which is where a lot of spoofing goes, sinceinvoices.yourdomain.comdoesn't need to exist for someone to forge it.
Interestingly, Gmail's own record is a reminder that big senders also migrate in steps:
$ dig +short TXT _dmarc.gmail.com
"v=DMARC1; p=none; sp=quarantine; rua=mailto:mailauth-reports@google.com"
How to move your own domain from monitoring to enforcement is in DMARC with p=none doesn't stop spoofing.
Forwarding and ARC
Forwarding breaks SPF, and mailing lists break DKIM, so a legitimate message passed through both can arrive failing DMARC. ARC (Authenticated Received Chain, RFC 8617) is the workaround: each intermediary records the authentication results it saw and signs them. The final receiver can then decide to trust a message that failed DMARC on arrival because a trusted forwarder vouches that it passed earlier. You don't configure ARC on your domain. It's something mail providers and list servers do, and it's why large mailbox providers handle forwarded mail better than small ones.
Reading the results on a real message
Every receiver records its verdict in an Authentication-Results header (RFC 8601). In Gmail it's under "Show original", in Outlook under "View message source". The format looks like this, with your own domains in place of the placeholders:
Authentication-Results: <receiver>;
dkim=pass header.i=@<signing-domain> header.s=<selector>;
spf=pass smtp.mailfrom=<envelope-domain>;
dmarc=pass (p=<policy>) header.from=<from-domain>
When DMARC fails, compare the three domains in that header: header.i for DKIM, smtp.mailfrom for SPF and header.from. If none of the passing ones align with header.from, that's your answer.
Encrypting the connection: MTA-STS and TLS-RPT
SPF, DKIM and DMARC authenticate the message. They don't make sure it travels encrypted. By default, SMTP encryption (STARTTLS) is opportunistic: if a connection can't be encrypted, mail is sent in plain text. MTA-STS lets a domain say "only deliver to my mail servers over verified TLS". It's a DNS record that points to a policy file:
$ dig +short TXT _mta-sts.gmail.com
"v=STSv1; id=20190429T010101;"
$ curl https://mta-sts.gmail.com/.well-known/mta-sts.txt
version: STSv1
mode: enforce
mx: smtp.google.com
mx: gmail-smtp-in.l.google.com
mx: *.gmail-smtp-in.l.google.com
max_age: 86400
TLS-RPT (_smtp._tls.gmail.com, here v=TLSRPTv1;rua=mailto:sts-reports@google.com) asks senders to report when they couldn't deliver securely. Once you enforce MTA-STS, your mail servers' certificates matter as much as your website's: if one expires, senders that respect your policy stop delivering.
The free check shows a domain's SPF, DKIM and DMARC setup, and whether DMARC is actually enforced: