Password Password

Security, explained for the people who have to fix it.

Attack and Defense

SPF, DKIM and DMARC explained, with what RFC 9989 changed

What SPF, DKIM and DMARC each check, why alignment is the part that stops spoofing, what the May 2026 DMARC standard changed, and a script to read your records.

Anyone can put your domain in the From line of an email. SPF, DKIM and DMARC are the three DNS records that let a receiving mail server tell your real mail from that kind of forgery, and they are now a delivery requirement as well as a defence: Google says mail to Gmail that fails them may be marked as spam or rejected. This article explains what each record actually checks, why "alignment" is the part that stops spoofing, what changed when DMARC became an IETF standard in May 2026, and a rollout order that does not lose legitimate mail. It ends with a small Python script that reads a domain's three records and points out the common faults, including the ones the new standard introduced. Before the script, it counts what 498 of the largest US companies actually publish in these records, read from public DNS on 4 November 2026.

We read five documents for this article on 2026-10-29: RFC 7208 (SPF), RFC 6376 with its RFC 8301 update (DKIM), and RFC 9989, the new DMARC standard, alongside the RFC 7489 text it replaces. Requirements quoted from Gmail come from Google's sender guidelines page, read the same day.

Three checks, three different domains

The confusing part of email authentication is that a message carries several domain names, and each check looks at a different one.

Check What it proves Which domain it checks Where the record lives
SPF The connecting server is allowed to send for a domain The envelope sender (SMTP MAIL FROM), or the HELO name A TXT record at the domain itself
DKIM A domain signed the message and the signed parts are unchanged The d= domain in the DKIM-Signature header A TXT record at selector._domainkey.domain
DMARC The domain in the visible From line matches a domain that passed SPF or DKIM The From header domain (RFC 9989 calls it the Author Domain) A TXT record at _dmarc.domain

Neither SPF nor DKIM looks at the From line your reader sees. A forger can send from a server their own domain authorises, so the message passes SPF for the forger's envelope domain, and sign it with their own key, so it passes DKIM for the forger's domain, while the visible From line says your domain. RFC 9989 says this directly about both: any domain owner, "even a bad actor, can publish an SPF record for its domain and send an email that will obtain an SPF 'pass' result", and a message "can bear a valid signature from any domain". DMARC is the record that closes the gap, which is why the other two are necessary but not sufficient.

SPF: a list of senders with a budget of ten lookups

An SPF record is a TXT record that starts with v=spf1 and lists who may send. Each term is checked from left to right, and the first one that matches decides the result through its qualifier: + pass (the default), - fail, ~ softfail, ? neutral. The record usually ends with all, which always matches and so sets the result for every sender not listed earlier.

example.net.  IN TXT  "v=spf1 mx include:_spf.mailprovider.example ip4:192.0.2.0/24 -all"

Three rules in RFC 7208 are worth knowing before anyone edits the record:

  • One record only. If a domain publishes two v=spf1 records, the check returns "permerror" (Section 4.5). That can happen when a second mail service's setup page says to add an SPF record and someone adds a new one instead of merging it into the existing record.
  • Ten lookups. The terms include, a, mx, ptr, exists and the redirect modifier each cost a DNS query, and Section 4.6.4 says implementations "MUST limit the total number of those terms to 10 during SPF evaluation". Includes count recursively: an include of a provider whose record has four more includes spends five. Past ten, the result is "permerror", and a sender that matches nothing in the record always evaluates every term, so it always gets that far. ip4, ip6 and all are free. The same section recommends a limit of two "void" lookups that return nothing.
  • include is not a paste. RFC 7208 admits that "the name 'include' was poorly chosen": the included record's result is only used if it is a pass, and a -all inside an included record does not end the outer check.

Two qualifiers deserve a warning. +all authorises every host on the internet. -all is the strict ending, and RFC 9989 Section 7.1 points out a side effect: a receiver that rejects on SPF failure early in the SMTP conversation may reject a message that would have passed DMARC through an aligned DKIM signature, and those messages "will never appear in aggregate DMARC reports". Neither ending is wrong; know which one you chose and why. The ptr mechanism "SHOULD NOT be published" at all (Section 5.5).

SPF also breaks on forwarding. When an alumni address or a role alias relays a message, the relay's IP address is not in your record, so SPF fails at the final mailbox unless the relay rewrites the envelope sender. RFC 9989 Section 7.4 describes exactly this case.

DKIM: a signature tied to a domain

DKIM signs selected headers and the body of each outgoing message. The signature header names the signing domain (d=) and a selector (s=), and the receiver fetches the public key from a TXT record at selector._domainkey.domain (RFC 6376 Section 3.6.2.1). Selectors let one domain have several keys at once, one per mail service, and let you rotate keys by publishing a new selector before retiring the old one. Publishing a key record with an empty p= tag revokes that key: RFC 6376 says signatures that use it should fail.

s2026._domainkey.example.net.  IN TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."

Key size is the setting most likely to be stale. RFC 8301 (January 2018) says signers "MUST use RSA keys of at least 1024 bits" and "SHOULD use RSA keys of at least 2048 bits", that verifiers "MUST NOT consider signatures using RSA keys of less than 1024 bits as valid", and that rsa-sha1 "MUST NOT be used" for signing or verifying. Google's guidelines match: sending to personal Gmail accounts "requires a DKIM key of 1024 bits or longer", and Google recommends 2048 bits where the provider supports it.

Unlike SPF, a DKIM signature generally survives a plain relay, because the signed content is unchanged; RFC 9989 relies on that, saying domains that publish p=reject "MUST apply valid DKIM signatures to their messages" rather than rely on SPF alone. A signature does not survive a mailing list that edits the message.

DMARC: alignment is the whole point

A DMARC record does two things. It asks receivers to check alignment, and it states what the domain owner wants done with mail that fails.

Alignment means the domain that passed SPF or DKIM must match the From line's domain. In relaxed mode, the default, the two must share an Organizational Domain, so a DKIM signature by mail.example.com aligns with a From line of news.example.com. In strict mode they must be identical. RFC 9989 notes that "nearly all Domain Owners have found relaxed alignment sufficient". A message passes DMARC if any one aligned identifier passed: SPF alone, DKIM alone, or both.

The record itself is a list of tags:

_dmarc.example.net.  IN TXT  "v=DMARC1; p=quarantine; rua=mailto:dmarc-reports@example.net"

v=DMARC1 must come first, and the value is case-sensitive. p= is the policy: none (no preference expressed), quarantine (treat failures as suspicious) or reject (failures are not valid use of the domain). rua= asks receivers to send daily aggregate reports; RFC 9989 says that without it, receivers "MUST NOT generate aggregate feedback reports", so a record with no rua= gives you no view of what is failing. sp= sets the policy for subdomains, and adkim= and aspf= choose strict or relaxed alignment for each mechanism.

The policy is a request, not a command. RFC 9989 says receivers "MUST NOT reject incoming messages solely on the basis of a 'p=reject' policy" and that, without other knowledge and analysis, they must treat such failures as if the policy were quarantine. DMARC also does nothing about display-name tricks, where the From line shows a familiar name with an unrelated address; the RFC lists those as out of scope.

What RFC 9989 changed in May 2026

DMARC ran for eleven years on RFC 7489, published in March 2015 as an Informational document rather than a standard. The IETF's DMARC working group replaced it in May 2026 with three Standards Track documents (all three are Proposed Standards): RFC 9989 for the protocol, RFC 9990 for aggregate reporting and RFC 9991 for failure reporting. The IETF Datatracker shows RFC 9989 as the published form of draft-ietf-dmarc-dmarcbis and lists it as obsoleting RFC 7489 and RFC 9091. The changes that matter to a domain owner:

Topic RFC 7489 (2015) RFC 9989 (2026)
Status Informational Proposed Standard
Finding the Organizational Domain A public suffix list, with no list or refresh rule mandated A DNS "Tree Walk" up the parent names, at most eight queries
Gradual rollout pct= 0 to 100, percentage of failing mail to apply the policy to pct= removed; t=y asks receivers to apply one level below the stated policy
Non-existent subdomains Only in RFC 9091 (Experimental, July 2021) New np= tag
Public suffix operators RFC 9091 registry New psd= tag
Report tags rf= and ri= Removed; reporting moved to RFC 9990 and RFC 9991
The p= tag Required Recommended; without it, a record with a valid rua= is read as p=none (the same fallback RFC 7489 had)

The pct change is the one most likely to affect existing records. RFC 9989 Appendix A.6 says operational experience showed pct "was usually not accurately applied, unless the value specified was either 0 or 100", and that pct=0 had taken on a special meaning: some intermediaries rewrote the From line when they saw it. The new t=y keeps that signal. With p=quarantine; t=y receivers are asked to apply none; with p=reject; t=y, quarantine. The IANA registry now lists pct, rf and ri as historic. In practice: replace pct=0 with t=y, delete pct=100 (it was the default), and treat any other pct value as a setting the new standard no longer defines.

The Tree Walk matters if you publish DMARC records on subdomains. A receiver looks for _dmarc at the From domain first, and if nothing is there it queries each parent in turn. For a deep name it skips straight to the last seven labels, so a 13-label domain costs eight queries in all. The Organizational Domain becomes the shortest name in the chain that has a DMARC record, unless a record carries psd=n (this is the Organizational Domain) or psd=y (this is a public suffix; the Organizational Domain is one label below it). RFC 9989 warns that receivers still running RFC 7489 code with a public suffix list may reach a different answer, and that this "is entirely avoided by the use of strict alignment and publishing explicit DMARC Policy Records for all Author Domains".

We could not find a published measurement of how many receivers have moved to RFC 9989 behaviour, so the safe assumption for now is that both kinds are reading your record.

What Gmail requires

Google's sender guidelines took effect on 1 February 2024 for mail to personal Gmail accounts. Every sender must set up SPF or DKIM, have valid forward and reverse DNS, use TLS, and keep the spam rate reported in Postmaster Tools below 0.3%. Senders of more than 5,000 messages a day to Gmail must have SPF and DKIM and DMARC, and Google says the DMARC enforcement policy "can be set to none". For those bulk senders, the From domain must be aligned with either the SPF domain or the DKIM domain, and marketing mail must support one-click unsubscribe. Unauthenticated mail "might be marked as spam or rejected with a 5.7.26 error".

So p=none with working, aligned SPF or DKIM is enough to meet the published Gmail requirement. It is not enough to stop someone sending mail as your domain, which is the reason to keep going.

A rollout order that does not lose mail

RFC 9989 Section 5.1 lays out the domain owner's steps, and Section 7.4 adds timings. In order:

  1. Make SPF list every service that sends as your domain, and keep it within ten lookups. A service missing from SPF and not signing with DKIM is exactly the mail that enforcement will quarantine or reject.
  2. Turn on DKIM signing with your own domain as d= at every sending service, using 2048-bit keys where the service allows it.
  3. Create a mailbox for aggregate reports, then publish p=none with rua= pointing at it.
  4. Read the reports. They list every source sending as your domain and whether it passed and aligned. RFC 9989 says reaching confidence "may take many months" for a domain that sends infrequently.
  5. Fix or remove every unaligned legitimate source, then move to p=quarantine. RFC 9989 says domains planning p=reject should first publish p=none "for at least a month, followed by publishing 'p=quarantine' for an equally long period of time".
  6. Move to p=reject only if your users do not post to public mailing lists, or after warning them. Section 7.4 says domains whose users "might post messages to mailing lists SHOULD NOT publish" p=reject, because lists that pass messages through unchanged cause rejections that can unsubscribe other members.

A domain that never sends mail is the simple case. An SPF record of v=spf1 -all authorises no server, and a DMARC record with p=reject says any mail using the domain is not valid. Under the definitions above, nothing legitimate can fail, so there is no monitoring period to wait out.

What 498 companies actually publish, read 4 November 2026

The sections above say what the records should contain. To see what large companies actually publish, we read the SPF and DMARC records of the S&P 500 companies on 4 November 2026.

  • Which companies. The constituents table of Wikipedia's "List of S&P 500 companies" (revision 1382178819, read 4 November 2026): 503 share listings, 500 companies. Each company's domain is the website named in the infobox of its own Wikipedia article, cut to the registrable domain, so www.example.com and investor.example.com both count as example.com. One listed company has no article, and one gives the same website as another listed company, so 498 domains were surveyed.
  • What we asked. For each domain, the TXT records at _dmarc.<domain> and at the domain itself, then the record of every name its SPF record includes or redirects to. All questions went to one public resolver (Cloudflare's 1.1.1.1), at most four a second: 1,798 distinct names between 13:52 and 14:00 UTC, 589 of them answered over TCP because the reply was too large for UDP, and none unanswered. We sent nothing to the companies' own servers; the resolver fetched the records from their DNS hosts in the normal way.
  • How it was counted. Every raw reply is saved. The survey script, email-auth-survey-sp500.py, re-reads those saved replies and applies the record checks of this article's own script, so every number below can be recomputed without asking DNS again. The counts are in email-auth-survey-sp500.csv: one row per group (all, or a sector) and measure, with the count, the denominator, the share and the day the records were read. We publish shares only and name no company.
DMARC record at the company's web domain Domains Share
p=reject 355 71.3%
p=quarantine 94 18.9%
p=none 41 8.2%
No DMARC record 8 1.6%

DMARC is close to universal here: 490 of the 498 domains (98.4%) publish a valid record, and 449 (90.2%) ask receivers to quarantine or reject mail that fails. No record failed to parse. Google requires a DMARC record, at any policy, from senders of more than 5,000 messages a day to Gmail, so the p=none rows still meet that rule; they just do not stop spoofing.

The tags tell a more mixed story:

  • pct is still common. 118 of the 490 records (24.1%) carry pct=, the tag RFC 9989 retired. 114 of them say pct=100, the old default, which can simply be deleted. Four set a partial value, all with p=quarantine, a setting the new standard no longer defines. None uses pct=0.
  • The new tags are barely used. No record uses t=, 2 use np= and 1 uses psd=. 86 (17.6%) still carry rf= or ri=, which RFC 9989 lists as historic.
  • Reports are switched on. 476 records (97.1%) ask for aggregate reports and 14 do not. In 410 (83.7%) at least one report address is at a domain other than the company's own. 396 (80.8%) also ask for failure reports (ruf=).
  • Subdomains and alignment. 21 records (4.3%) set sp= to a weaker policy for subdomains than p= sets for the domain. Relaxed alignment is the norm: adkim=s appears in 6 records and aspf=s in 8.
How the SPF record ends Domains Share of those with SPF
-all (fail) 242 49.4%
~all (softfail) 246 50.2%
?all (neutral) 2 0.4%
+all (pass everything) 0 0.0%

490 of the 498 domains publish an SPF record. Half end it with -all and half with ~all, which, as the SPF section notes, is a choice with trade-offs rather than a fault. One domain publishes two SPF records, which RFC 7208 makes a permerror. The fault that does show up is the lookup budget: 14 domains (2.9%) need more than ten DNS-lookup terms, counted the way the script counts them (every term evaluated, macros not expanded), and another 70 (14.3%) sit at nine or ten, one new include away from the limit. Counting every way an unlisted sender's SPF check ends in permerror here (two records, an include with no SPF record, more than ten lookups), 16 of the 490 SPF domains (3.3%) are affected. The median record spends 3 lookups.

174 domains (34.9%) pair p=reject with an SPF -all ending, the strictest combination. Four domains publish neither SPF nor DMARC. If a domain sends no mail, the two-record setup described in the rollout section (v=spf1 -all and p=reject) would close it at no cost.

By sector, using the GICS sectors in the same Wikipedia table:

GICS sector Companies p=reject p=quarantine p=none No DMARC record SPF -all SPF over 10 lookups
Communication Services 19 79% 11% 11% 0% 42% 5%
Consumer Discretionary 47 68% 15% 13% 4% 42% 2%
Consumer Staples 34 82% 12% 3% 3% 44% 3%
Energy 21 57% 29% 10% 5% 76% 5%
Financials 76 83% 12% 4% 1% 50% 5%
Health Care 59 73% 19% 8% 0% 46% 3%
Industrials 82 78% 13% 7% 1% 58% 4%
Information Technology 75 67% 27% 7% 0% 52% 1%
Materials 24 42% 46% 8% 4% 35% 0%
Real Estate 30 63% 17% 20% 0% 33% 0%
Utilities 31 61% 26% 10% 3% 57% 0%

Financials (83%) has the highest share at p=reject. Materials (42% reject, 46% quarantine) has the lowest, and more of it sits at quarantine instead. The sectors hold 19 to 82 companies, so one company moves a sector's share by about 1 to 5 points; read the sector rows as rough.

What this does and does not measure. The website in the infobox is not always the domain a company sends mail from, and a group may send from several; these numbers describe the records at the domain each company presents as its website. DKIM is not counted, because keys sit at selector names that cannot be listed from DNS. A DMARC policy is a request to receivers, so p=reject here says what a company asks for, not what receivers do with its mail. And the S&P 500 is 500 of the largest US-listed companies: this survey says nothing about smaller organisations.

Reading your own records with the script

The script in the Code and data box uses only the Python standard library. It sends DNS TXT queries to a resolver of your choice and nothing else. For a domain it follows the SPF includes and counts lookup terms, finds the DMARC record by the RFC 9989 Tree Walk and checks its tags, and, for each DKIM selector you name, decodes the public key and reports its size. Selectors cannot be listed from DNS; take yours from the s= tag of the DKIM-Signature header in a message your domain sent.

python spf-dkim-dmarc-explained-rfc-9989.py --selftest
python spf-dkim-dmarc-explained-rfc-9989.py --demo
python spf-dkim-dmarc-explained-rfc-9989.py your-domain.example --selector s1 --selector s2

The self-test rebuilds the worked examples from RFC 9989 Appendix B and Section 4.10, the vanity-domain example from RFC 7208, and key-size cases, and prints selftest: 35 checks passed. The demo runs the full report against a made-up zone, built from documentation domain names, with three faults planted in it. This is its real output:

== example.net

SPF  (16 of 10 DNS-lookup terms used)
  example.net: v=spf1 mx include:_spf.example.net include:esp.example.org ~all
    _spf.example.net: v=spf1 ip4:192.0.2.0/24 include:_spf2.example.net -all
      _spf2.example.net: v=spf1 a mx exists:%{i}._ip.example.net -all
    esp.example.org: v=spf1 include:a.esp.example.org include:b.esp.example.org include:c.esp.example.org ~all
      a.esp.example.org: v=spf1 a mx ip4:198.51.100.0/24 ~all
      b.esp.example.org: v=spf1 a mx ip4:198.51.100.0/24 ~all
      c.esp.example.org: v=spf1 a mx ip4:198.51.100.0/24 ~all
  ! example.net: 16 DNS-lookup terms (limit 10, RFC 7208 Sec. 4.6.4): a check that gets past the 10th ends in permerror, as does every unlisted sender

DMARC
  tree walk queried: _dmarc.example.net, _dmarc.net
  policy record at _dmarc.example.net: v=DMARC1; p=quarantine; pct=0; rf=afrf; rua=mailto:dmarc-reports@example.net
  organizational domain: example.net; policy taken from the p= tag (= quarantine)
  ! pct= (sampling rate) is historic in RFC 9989. pct=0 -> publish t=y instead.
  ! rf= (failure report format) is historic in RFC 9989.

DKIM s2019._domainkey.example.net
  - RSA 1024 bits: valid, but RFC 8301 says signers SHOULD use at least 2048

DKIM s2026._domainkey.example.net
  - RSA 2048 bits

The Tree Walk itself is short. This is the function that lists the names a receiver queries:

def walk_names(domain):
    """The names a DNS Tree Walk queries, RFC 9989 Sec. 4.10: the start, then one label shorter
    each time, except that a name of eight or more labels jumps straight to its last seven."""
    labels = domain.rstrip(".").lower().split(".")
    names = [".".join(labels)]
    while len(labels) > 1:
        labels = labels[-7:] if len(labels) >= 8 else labels[1:]
        names.append(".".join(labels))
    return names

What this does not cover

The lookup count is a worst case: it assumes every term is evaluated, does not expand SPF macros such as %{i}, and does not count the address lookups each mx term triggers, which RFC 7208 caps separately at ten per term. The script reads records; it does not send or verify a signed message, so it cannot tell you whether your mail services actually sign with the keys you published. It treats the Tree Walk as RFC 9989 defines it, and a receiver still on RFC 7489 may reach a different Organizational Domain for unusual subdomain layouts. Lookalike domains and display-name forgery are outside DMARC, and outside this script. For those, the defences are user-facing: showing the full sender address, flagging external mail, and registering the obvious misspellings of your domain.

Update, 4 November 2026: added "What 498 companies actually publish": the SPF and DMARC records of the S&P 500 companies' web domains, read from public DNS on 4 November 2026, with the survey script and the aggregate counts. The rest of the article is unchanged, apart from one sentence in the introduction.

Everything on this site is written for defenders and for people securing systems they own or are authorised to test. It describes how attacks work so they can be recognised and closed; it is not a guide to accessing anyone else's systems.

Sources

  1. IETF, RFC 9989 "Domain-Based Message Authentication, Reporting, and Conformance (DMARC)" (Standards Track, May 2026; read 2026-10-29)
  2. IETF, RFC 9990 "Domain-Based Message Authentication, Reporting, and Conformance (DMARC) Aggregate Reporting" (Standards Track, May 2026)
  3. IETF, RFC 9991 "Domain-Based Message Authentication, Reporting, and Conformance (DMARC) Failure Reporting" (Standards Track, May 2026)
  4. IETF Datatracker, draft-ietf-dmarc-dmarcbis record (published as RFC 9989; obsoletes RFC 7489 and RFC 9091)
  5. IETF, RFC 7489 "DMARC" (Informational, March 2015; the pct tag definition)
  6. IETF, RFC 7208 "Sender Policy Framework (SPF) for Authorizing Use of Domains in Email, Version 1" (April 2014)
  7. IETF, RFC 6376 "DomainKeys Identified Mail (DKIM) Signatures" (September 2011)
  8. IETF, RFC 8301 "Cryptographic Algorithm and Key Usage Update to DKIM" (January 2018)
  9. Google, "Email sender guidelines" (Gmail sender requirements; read 2026-10-29)
  10. Wikipedia, "List of S&P 500 companies" (revision 1382178819, read 2026-11-04; the company list and GICS sectors; each company's website from its own article's infobox, read the same day)
  11. Cloudflare, "1.1.1.1" public DNS resolver (the resolver every survey query went to, 2026-11-04)