Email authentication (SPF, DKIM and DMARC)
A receiving mail server uses email authentication to check whether a message that uses a domain name was sent with the permission of that domain's owner. Three standards do the work, each through a record the owner publishes in DNS. SPF (Sender Policy Framework, RFC 7208) lists the servers allowed to send for the domain.1 DKIM (DomainKeys Identified Mail, RFC 6376) adds a cryptographic signature to each message.2 DMARC (Domain-based Message Authentication, Reporting, and Conformance) connects the two to the address the reader sees and states what receivers should do with mail that fails; its current version, RFC 9989 of May 2026, replaced RFC 7489 and RFC 9091.3 A domain that publishes none of the three is open to email spoofing.
Identities in a message
The protocol that carries mail between servers, SMTP, puts no limit on the sender names a connecting server may claim.1 A message carries several of them. The envelope sender, called MAIL FROM, is the reverse path given in the SMTP transaction, and HELO is the name the sending server gives for itself when it connects. The From: line inside the message is what the mail program shows to the reader; DMARC calls its domain the Author Domain. SPF checks the envelope and DKIM checks whichever domain signed the message, so neither says anything about the From: domain until DMARC ties them to it.3
SPF
An SPF record is a DNS TXT record at the domain itself, beginning with v=spf1.1 The receiver reads its terms from left to right and stops at the first one that matches the connecting server's IP address. Each term carries a qualifier: + gives pass, - fail, ~ softfail and ? neutral, and a term written without one counts as +. When nothing matches, the result is neutral, so a record has to end in -all for a receiver to be told plainly that unlisted servers are not allowed.
Two further rules produce the result permerror, which means the record cannot be read. The terms include, a, mx, ptr, exists and redirect each cost a DNS lookup, and a receiver allows at most 10 of them in one check. A domain with two SPF records fails the same way for every message, genuine ones included.1 A domain that sends only through Google Workspace publishes v=spf1 include:_spf.google.com ~all, with one more include for each extra sending service.4 A domain that sends no mail at all can publish v=spf1 -all, which authorizes no server.
DKIM
The sending server signs each message and adds a DKIM-Signature header. Its tags name the signing domain (d=), a selector (s=), the list of signed header fields (h=), a hash of the body (bh=) and the signature (b=). The receiver joins selector and domain into a DNS name, for example brisbane._domainkey.example.com, reads the public key published there and checks the signature with it.2 A body that no longer matches bh= makes the signature fail. A forwarder that leaves the body and the signed headers unchanged keeps the signature valid. Forwarding affects SPF differently. The forwarding server is not listed in the original domain's record, so forwarders rewrite MAIL FROM into their own domain, as almost all mailing lists do, and the SPF check then applies to that domain instead.1
RFC 6376 requires RSA keys of at least 1,024 bits for long-lived keys; Gmail requires the same length and recommends 2,048 bits.5 The signer keeps the private key, and the public key sits in the domain's DNS.
DMARC
A message passes DMARC when SPF or DKIM passes for a domain that is aligned with the Author Domain. In relaxed alignment, the default, the two need the same organizational domain, so foo.example.com aligns with news.example.com. Strict alignment, set with aspf=s or adkim=s, needs identical names. Alignment is required because a bad actor can publish SPF for a domain of their own, or sign with it, and receive a pass; only a passing domain that matches the From: domain says anything about the From: domain.3
The policy is a TXT record at _dmarc under the domain. Its p tag takes one of three values: none expresses no preference, quarantine marks failing mail as suspicious, and reject states that such use of the domain is not valid. The sp tag sets a policy for subdomains, and rua gives the address for aggregate reports; with no rua, receivers send none. Owners usually begin with p=none and a report address, a stage RFC 9989 calls Monitoring Mode, and use the reports to find and fix gaps in their own sending before they choose quarantine or reject. Receivers are not bound to follow the policy or to send reports.3
| Standard | DNS name | Checks |
|---|---|---|
| SPF | example.com | The sending server's address against the envelope domain |
| DKIM | <selector>._domainkey.example.com | The signature against the signing domain's public key |
| DMARC | _dmarc.example.com | That SPF or DKIM passed for a domain aligned with From:, and what to do when neither did |
Setting up a sending domain
An app at example.com that sends sign-in and password-reset mail through Amazon SES and nothing else would publish records of this form, with the selector and key supplied by the provider:
example.com. TXT "v=spf1 include:amazonses.com ~all"
s1._domainkey.example.com. TXT "v=DKIM1; p=<public key from the provider>"
_dmarc.example.com. TXT "v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com"Supabase's built-in mail server sends at most 2 messages per hour and is meant for testing. A project in production connects its own mail service and sets up SPF, DKIM and DMARC with it.6 Since 1 February 2024, Gmail has required SPF or DKIM from every sender, and SPF, DKIM, DMARC and an aligned From: from senders of more than 5,000 messages a day. A p=none policy meets that requirement. Mail without authentication may go to spam or be refused with error 5.7.26.5 The DMARC standard recommends publishing both SPF and DKIM.3
Limits
DMARC protects only the exact domain. It does nothing against a look-alike domain registered by someone else, or against a misleading display name in front of the address (see Phishing).3 A p=reject policy can also stop genuine mail that passes through forwarders, role aliases and mailing lists. A domain whose users post to mailing lists should study its aggregate reports before it publishes p=reject.3 Mailing list software has adopted workarounds that rewrite the From: line so relayed mail stays aligned.
In SecFlash
On the Email and domain page, SecFlash reports a missing SPF record as SF-EML-101, a missing DMARC record as SF-EML-102 and a DMARC policy of p=none as SF-EML-103. SPF records that end in +all, have no all rule or end in ?all are SF-EML-104, SF-EML-105 and SF-EML-106. Two SPF records are SF-EML-107 and more than 10 lookups SF-EML-108. SF-EML-109 reports that no DKIM key was found, and SF-EML-110 a DMARC record with no rua address.
See also
References
- a b c d e Kitterman, S. (April 2014). "RFC 7208: Sender Policy Framework (SPF) for Authorizing Use of Domains in Email, Version 1". RFC Editor. IETF.
- a b Crocker, D., Hansen, T. and Kucherawy, M., eds. (September 2011). "RFC 6376: DomainKeys Identified Mail (DKIM) Signatures". RFC Editor. IETF.
- a b c d e f g Herr, T. and Levine, J., eds. (May 2026). "RFC 9989: Domain-based Message Authentication, Reporting, and Conformance (DMARC)". RFC Editor. IETF.
- back "Set up SPF". Google Workspace Admin Help. Google.
- a b "Email sender guidelines". Google Workspace Admin Help. Google.
- back "Send emails with custom SMTP". Supabase Docs. Supabase.
External links
- RFC 7208: Sender Policy Framework, RFC Editor
- RFC 9989: DMARC, RFC Editor