SPF, DKIM and DMARC: How to Check and Fix a Domain's Email Security
Email was designed without any way to prove who sent a message. Anyone can put your domain in the From line. SPF, DKIM and DMARC are three DNS records that let receiving servers check whether a message claiming to be from your domain really is, and decide what to do when it is not.
Why all three are needed
Each record checks something different, and each has a gap that the others cover.
| Record | Where it lives | What it checks | Its gap on its own |
|---|---|---|---|
| SPF | TXT on the domain itself | Whether the sending server's IP address is allowed to send for the envelope sender domain | Checks the hidden envelope address (Return-Path), not the From address people see. Breaks when mail is forwarded. |
| DKIM | TXT at selector._domainkey.domain | A cryptographic signature over the message headers and body | The signing domain does not have to match the visible From address. |
| DMARC | TXT at _dmarc.domain | That SPF or DKIM passed and the passing domain matches the visible From domain; then applies your policy | Depends on at least one of the other two being set up correctly. |
The matching requirement is called alignment, and it is what turns two technical checks into protection for the address a person actually reads.
Reading an SPF record
An SPF record is a TXT record starting with v=spf1. For example:
v=spf1 ip4:198.51.100.25 include:_spf.mail-provider.example mx -all
ip4:198.51.100.25allows one specific server.ip6:does the same for IPv6, and both accept CIDR ranges.include:pulls in another domain's SPF list, which is how you authorize an email provider or a newsletter service.mxandaallow the servers in the domain's MX or A records.- The final
allsays what to do with everything else:-allmeans fail,~allmeans soft fail (accept but treat as suspicious), and?allmeans neutral.+allallows the whole internet and defeats the purpose.
The two SPF mistakes that break everything
- More than one SPF record. A domain must have exactly one TXT record starting with
v=spf1. When a second service tells you to "add this SPF record", merge itsinclude:into your existing one instead. Two records produce a permanent error, and receivers treat SPF as failed. - Too many DNS lookups. The SPF standard (RFC 7208) limits evaluation to 10 DNS lookups. Each
include,a,mxand redirect counts, and so do the includes inside included records. A domain that uses an office suite, a CRM, a help desk and two marketing tools can pass the limit without anyone noticing, and the result is again a permanent error. Remove services you no longer use, and prefer a provider's single include over listing several of theirs.
Reading DKIM
With DKIM, the sending server signs each message with a private key and adds a DKIM-Signature header. The header names a domain (d=example.com) and a selector (s=s1). The receiver fetches the public key from s1._domainkey.example.com and checks the signature. Any change to the signed parts of the message in transit makes it fail.
Selectors let one domain have several keys at once, one per sending service, and they make key rotation possible: publish a new selector, switch signing to it, then remove the old one. Because selector names are chosen by each provider, nobody can list all of a domain's DKIM keys from DNS alone. The domain lookup checks common selector names, so "not found" there means only that no common selector was found. The reliable way to find a selector is to open the full headers of a real message from the domain and read the s= value.
Every service that sends mail as your domain, including newsletters, invoicing and support systems, should sign with your domain rather than its own. Most providers give you one or more CNAME or TXT records to publish for this.
Reading DMARC
A DMARC record is a TXT record at _dmarc.example.com. A typical starting record looks like this:
v=DMARC1; p=none; rua=mailto:[email protected]
p=is the policy for mail that fails:none(monitor only),quarantine(treat as spam) orreject(refuse it).rua=is where receivers send daily aggregate reports, XML summaries of which servers sent mail as your domain and whether it passed.sp=sets a separate policy for subdomains. Without it, subdomains inheritp=.pct=applies the policy to only a percentage of failing mail, which some receivers honour during a gradual rollout.adkim=andaspf=choose relaxed (the default; subdomains count as matching) or strict alignment.
A p=none policy protects nothing by itself. It is a monitoring mode, and it is where every domain should start, but the goal is to move beyond it.
A safe order for moving to enforcement
- Inventory senders. List every system that sends mail with your domain in the From line: your mailbox provider, website contact forms, billing, marketing and support tools.
- Publish SPF covering them, within the 10-lookup limit, ending in
~allwhile you are still discovering senders. - Turn on DKIM signing with your domain for each sender.
- Publish DMARC with
p=noneand a reporting address. Read the aggregate reports for two to four weeks. A report-processing service makes the XML far easier to read. - Fix what the reports show. Any legitimate source that fails needs SPF or DKIM aligned before you go further.
- Move to
p=quarantine, optionally with a lowpctat first, and keep watching. - Move to
p=rejectonce reports show only illegitimate mail failing. Tighten SPF to-allat the same time if you like.
Large mailbox providers have tightened their requirements in recent years. Gmail and Yahoo, for example, began requiring bulk senders to authenticate with SPF and DKIM and to publish a DMARC record in 2024. Even small senders see better delivery with all three in place.
Domains that never send mail
Parked domains and domains used only for a website are easy targets for spoofing because nobody watches them. Lock them down with three records:
- SPF that allows nothing:
v=spf1 -all - DMARC that rejects everything:
v=DMARC1; p=rejectat_dmarc - A null MX (
0 .) if the domain should not receive mail either
Checking a domain
The Email Security panel on the GotInfo domain lookup reads the SPF, DMARC and common DKIM records for any domain. Use it to check your own domains after a change, or to see whether a sender you received suspicious mail from has a policy that should have stopped it. For a single message, the Authentication-Results header your mail provider adds shows exactly which checks passed and failed. The DNS record types guide covers the other records that affect delivery, such as MX and PTR.
Check SPF, DKIM and DMARC for any domain: open the GotInfo domain lookup.