Definition
- SPF (Sender Policy Framework) is a TXT record on the domain itself that starts with
v=spf1, with which the domain owner names the hosts allowed to use its domain (RFC 7208). The standard checks theMAIL FROMandHELOdomains of the SMTP session; it does not itself check the domain of theFromfield the reader sees. - DKIM (DomainKeys Identified Mail) is a digital signature the sending server adds in a
DKIM-Signatureheader. It covers the message body and selected header fields, which must includeFrom. The signature names the signing domain in itsd=tag and a selector in itss=tag, and the public key is a DNS TXT record namedselector._domainkey.domain(RFC 6376). A valid signature shows that the signing domain takes responsibility for the message. - DMARC is a TXT record named
_dmarcon the domain, starting withv=DMARC1. With it the domain owner says what should happen to mail that carries the domain inFromand fails the checks, and asks for reports (RFC 7489). It builds on SPF and DKIM rather than replacing them: a message passes DMARC if at least one of them passes with a domain aligned with theFromdomain. Theptag isnone,quarantineorreject, andruais an address for aggregate reports.
Why it matters
- Without these records, receiving mail servers cannot tell whether a message carrying your domain was sent by a server you authorised, or what to do with one that fails. Google says SPF helps prevent others from impersonating you, DKIM prevents message contents from being changed in transit, and DMARC lets you choose what happens to messages that fail them.
- Gmail asks everyone who sends to Gmail accounts to set up SPF or DKIM. Anyone sending more than 5,000 messages a day to them needs SPF, DKIM and DMARC, and Google allows the DMARC policy to be
none. - A domain that never sends mail needs the records too: M3AAWG recommends the SPF record
v=spf1 -all, which says no host is allowed, and a DMARC record withp=reject. - Arablyzer's email security check looks at SPF and DMARC but not DKIM: the DKIM key sits in DNS under a selector each mail service chooses, as RFC 6376 (section 3.6.2.1) says, so a page check cannot know where to look.
Example
The records of a domain that sends its mail through Google Workspace alone:
dns
example.com. TXT "v=spf1 include:_spf.google.com ~all"
selector1._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkq..."
_dmarc.example.com. TXT "v=DMARC1; p=none; rua=mailto:[email protected]"- The first lets Google's servers send for the domain.
~allmakes everything else asoftfail(RFC 7208, section 4.6.2). - The second publishes the public key for the selector
selector1; signatures on that server's mail carryd=example.comands=selector1. - The third announces the policy
none, so it asks nobody to change anything yet, and requests aggregate reports at[email protected].
Common mistakes
- More than one SPF record on the domain: RFC 7208 (section 4.5) treats it as a permanent error,
permerror, so none is read. Put every service in a single record. - More than 10 SPF terms that cause DNS queries, namely
include,a,mx,ptr,existsandredirect: RFC 7208 (section 4.6.4) requires implementations to returnpermerrorthen. - Setting up DMARC before SPF and DKIM work: Google advises waiting 48 hours after setting them up, and starting with the policy
nonebefore tightening toquarantineorreject. - Assuming a pass from SPF or DKIM alone satisfies DMARC: the domain that passed has to match the
Fromdomain (RFC 7489, section 3.1). - Leaving a domain that never sends mail without records, so its name stays open to impersonation.