Guide
SPF, DKIM and DMARC explained
What each record does, how they work together, and the order to set them up in.
Updated
Email was designed without any way to prove who sent a message. Anyone can put ceo@yourcompany.com in the From line. SPF, DKIM and DMARC are three DNS records that
close that gap. Together they let a receiving mail server check that a message really comes from your
domain, and tell it what to do when it doesn’t.
They also decide a lot of your deliverability. Gmail, Yahoo and Microsoft now require all three from anyone sending in bulk, and mail without them is far more likely to land in spam or be refused.
SPF: which servers may send
SPF (Sender Policy Framework) is a TXT record at your domain listing the servers allowed to send email for it:
v=spf1 include:_spf.google.com include:sendgrid.net ~all This one says “Google Workspace’s servers and SendGrid’s servers may send for us; treat
everything else with suspicion (~all)”. A receiving server checks the IP address of
the server that connected to it against that list.
Its limits: SPF checks the domain in the hidden return path (the “envelope from”), not the From address people see, and it breaks when mail is forwarded, because the forwarding server isn’t on your list. It also allows only 10 DNS lookups; see fixing too many DNS lookups.
DKIM: a signature on every message
With DKIM (DomainKeys Identified Mail), your email service adds a cryptographic signature to
each message’s headers. The public key that verifies it is published in DNS at selector._domainkey.yourdomain.com. If the signature checks out, the receiver knows
the message was sent by someone holding your private key and wasn’t changed on the way.
DKIM survives forwarding, which makes it the more reliable of the two. You don’t write the
record yourself: you turn DKIM on in each email service’s settings, and it gives you the record
to publish. The selector lets each service have its own key; see how to find your DKIM selector.
DMARC: the policy that ties them together
SPF and DKIM on their own don’t protect the From address. A spammer can send from their own domain with perfect SPF and DKIM and still put your domain in the From line. DMARC fixes that with alignment: a message passes DMARC only if SPF or DKIM passes for the same domain as the From address.
DMARC is a TXT record at _dmarc.yourdomain.com:
v=DMARC1; p=quarantine; rua=mailto:dmarc@yourdomain.com p= is the policy for mail that fails: none (deliver anyway, just
report), quarantine (spam folder) or reject (refuse). rua= is where receivers send daily reports of every server that sent mail as your domain,
which is how you find out what you’d break before you tighten the policy.
How a receiver uses all three
- A message arrives claiming to be from
you@example.com. - The receiver checks SPF for the return-path domain and verifies any DKIM signatures.
- It looks up
_dmarc.example.comand checks whether either passing result is forexample.com(or a subdomain of it, with the default relaxed alignment). - If one is, DMARC passes. If neither is, it applies your policy and records the result in the report it sends you.
The order to set them up
- List every service that sends as your domain: your mailbox provider, your newsletter tool, your CRM, your helpdesk, your website’s contact form, your billing system.
- Publish one SPF record with an include for each, ending in
~all. - Turn on DKIM in each service, signing with your own domain, and publish the records they give you.
- Publish DMARC at
p=nonewith a report address, and read the reports for two to four weeks. - Tighten to
quarantine, thenrejectonce every legitimate source passes. Step-by-step: moving DMARC from none to reject.
Domains that never send email
Parked domains and domains used only for a website are favourite targets for spoofing, because nobody watches them. Lock them down with two records:
example.com TXT "v=spf1 -all"
_dmarc.example.com TXT "v=DMARC1; p=reject" The first says no server may send for the domain; the second tells receivers to refuse anything that claims to.
Related tools
All toolsEmail Domain Health Check
SPF, DKIM, DMARC and MX checked together, with a score and a list of fixes.
SPF Record Checker
Validate an SPF record, follow every include and count DNS lookups against the limit of 10.
DKIM Record Checker
Find DKIM keys under common selectors, or check your own, with key size and problems.
DMARC Record Checker
Read a domain’s DMARC policy in plain words and see what to change before tightening it.
More guides
- Gmail, Yahoo and Microsoft sender requirements What the big mailbox providers require of senders, and how to check you meet it.
- Fix “SPF permerror: too many DNS lookups” Why SPF stops at 10 lookups, how to count yours, and four ways to get under the limit.
- Moving DMARC from p=none to p=reject A safe, step-by-step path to full DMARC enforcement without losing legitimate mail.