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. Three DNS records let receiving servers tell your mail from forged mail: SPF lists the servers that may send for the domain, DKIM signs each message, and DMARC tells receivers what to do with mail that passes neither check for the From domain.
SPF: which servers may send
An SPF record (RFC 7208) is a TXT record on the domain:
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 (soft fail): SPF marks all other senders as suspect, and a DMARC policy ofquarantineorrejectdecides what happens to their mail.-all(fail) lets a receiver refuse a message during the SMTP session before it looks at DMARC, which loses forwarded mail that DKIM would pass (RFC 9989, section 7.1). Use-allfor domains that do not send mail.
Limits of SPF:
- Publish one SPF record. Two TXT records starting with
v=spf1make SPF fail with a permanent error; merge them. - Stay at or under 10 DNS lookups. Each
include,a,mx,ptr,existsandredirectcounts, including those inside included records. Over 10, SPF fails. Remove providers you no longer use;ip4:andip6:do not count. - SPF checks the envelope sender, the address in the SMTP
MAIL FROM, not the From line people see. It also fails 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
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.
Publish one record at _dmarc, starting with v=DMARC1 in capitals. Receivers discard all of them when there are two or more, and ignore a record that starts with v=dmarc1.
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 specified in RFC 9990 and failure reports in RFC 9991. Changes 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.
Records with pct=100 still work, because 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). Keep SPF at~all: the DMARC policy handles the mail that fails.
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
A parked domain, or one used only for a website, can be forged in phishing mail like any other. Three records close it:
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
DNSSEC signs DNS answers, so a resolver can detect forged SPF, DKIM and DMARC records. Where the DNS provider supports 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, one record andv=DMARC1in section 4, SPF-allin section 7.1), 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 Vulnpocalypse collector reports the packages and settings of a server once a day, and the digest lists what to fix, most urgent first.
Vulnpocalypse