Guides / Web servers and domains
SPF, DKIM and DMARC: stop others from sending mail as your domain
Anyone can send an e-mail with your domain in the From line. Whether the receiving server believes it depends on three DNS records: SPF says which servers may send for the domain, DKIM signs messages, and DMARC tells receivers what to do when neither checks out. Without them, phishing mail in your name is easy and your own mail lands in spam more often.
SPF: which servers may send
An SPF record (RFC 7208) is a TXT record on the domain that lists the servers allowed to send mail for it:
example.com. TXT "v=spf1 mx include:_spf.mailprovider.example -all"
mx: the mail servers of the domain may send;ip4:/ip6:add addresses;include:adds the record of a provider (your mail host, newsletter tool, ticket system).-allat the end: everything else fails.~all(soft fail) asks receivers to accept but mark the mail; use it while you are still finding all senders.
Rules that catch people out:
- One record only. Two TXT records starting with
v=spf1make SPF fail with a permanent error. Merge them. - At most 10 DNS lookups. Each
include,a,mx,ptr,existsandredirectcounts, including those inside included records. Over 10, SPF fails. Remove providers you no longer use. - SPF checks the envelope sender, the address in the SMTP
MAIL FROM, not the From line people see. It also breaks when mail is forwarded, because the forwarding server is not in your record.
dig +short TXT example.com | grep spf1
DKIM: a signature on each message
With DKIM (RFC 6376) the sending server signs headers and body of each message. The signature names a domain (d=) and a selector (s=); the public key is published in DNS under the selector:
selector1._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqh..."
Your mail provider generates the key and tells you the record to publish, often as a CNAME to a record they manage, so they can rotate keys. Check a published key with:
dig +short TXT selector1._domainkey.example.com
The selector of a message is in its DKIM-Signature: header (s=). DKIM survives most forwarding, because the signed content does not change.
DMARC: tie it to the From line and set a policy
DMARC connects SPF and DKIM to the From address people see. A message passes DMARC when SPF or DKIM passes for a domain that matches the From domain ("alignment"). The record at _dmarc.<domain> says what a receiver should do with mail that fails, and where to send reports:
_dmarc.example.com. TXT "v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com"
p=none: only report.p=quarantine: treat failing mail as suspicious (spam folder).p=reject: refuse it.rua=: where receivers send daily aggregate reports (XML): which servers sent mail as your domain and whether it passed.sp=: policy for subdomains;np=: policy for subdomains that do not exist.
What changed with RFC 9989
In May 2026 the IETF published DMARC as RFC 9989, a Proposed Standard that replaces RFC 7489 and RFC 9091. Aggregate reports are now RFC 9990 and failure reports RFC 9991. Changes that matter for a domain owner:
- The
pcttag is removed. For testing a stricter policy there ist=y: receivers then apply one level less (quarantine instead of reject, none instead of quarantine). - The
rfandritags are removed. np(policy for non-existent subdomains) is part of the standard.pis recommended rather than required; a record without it counts asp=none.- Receivers find the organizational domain by walking up the DNS tree, instead of using the Public Suffix List.
- The RFC states that domains with ordinary users who post to mailing lists should not publish
p=reject, because mailing lists and forwarders break SPF and sometimes DKIM. A domain withp=rejectmust sign all its mail with DKIM and must not rely on SPF alone.
Existing records with pct=100 keep working; receivers ignore tags they do not know.
A rollout that does not lose mail
- Publish SPF with
~alland set up DKIM at every service that sends as your domain. - Publish DMARC with
p=noneand aruaaddress. Read the reports for two to four weeks; a free or paid report viewer makes the XML readable. - Fix every legitimate sender that fails (a forgotten newsletter tool, the invoicing system).
- Move to
p=quarantine, then top=rejectfor domains that send only machine mail (invoices, notifications). Switch SPF to-all.
Check the result on a message you received: the Authentication-Results: header shows spf=pass, dkim=pass and dmarc=pass.
Domains that never send mail
Parked domains and domains used only for a website are popular for phishing because nobody watches them. Lock them down with three records:
example.net. TXT "v=spf1 -all"
_dmarc.example.net. TXT "v=DMARC1; p=reject;"
example.net. MX 0 .
The last line is a "null MX" (RFC 7505): the domain does not accept mail.
DNSSEC
SPF, DKIM and DMARC records are only as trustworthy as the DNS answers that carry them. DNSSEC signs those answers so a resolver can detect forged ones. If your DNS provider offers it, turning it on is usually a switch at the provider plus a DS record at the registrar:
dig +short DS example.com # empty: the domain is not signed
Sources
- RFC 7208: SPF (one record, 10 lookups, MAIL FROM)
- RFC 6376: DKIM
- RFC 9989: DMARC, May 2026 (tags, removed
pct/rf/ri,tandnp, DNS tree walk, interoperability withp=reject), with RFC 9990 and RFC 9991 - RFC 7505: A "Null MX" No Service Resource Record
- RFC 8601: Authentication-Results header field
- RFC 4033: DNS Security Introduction and Requirements
Check your servers every day
The agent of Patchbrief reports the packages and settings of a server once a day; the digest names what to fix first.