SPF, DKIM and DMARC explained (and how to set them up)
Email was designed in an age when everyone trusted everyone. Anyone can put any address in the "From" line, in the same way that anyone can write any return address on an envelope. That's why scammers can send messages that appear to come from your bank, or from your own company. SPF, DKIM and DMARC are the fixes that were added later. They don't stop people trying, but they let receiving mail servers check whether a message is genuine.
SPF: who is allowed to send
Sender Policy Framework is a list, published in your domain's DNS, of the servers allowed to send email for your domain. When a message arrives, the receiving server looks up that list and checks whether the server that delivered it is on it.
A typical SPF record for a business on Microsoft 365 looks like this:
v=spf1 include:spf.protection.outlook.com -all
The include part says "Microsoft's servers are allowed", and -all says "nothing
else is". Each service that sends email as your domain (your email provider, a newsletter system, your website's
contact form, a helpdesk) needs its own entry.
SPF's limits
- One record only. A domain must have exactly one SPF record. Two records, often added by two different suppliers, break SPF completely.
- The 10-lookup limit. Checking a record may involve no more than 10 DNS lookups. Every
include,aandmxuses at least one, and includes can contain more of their own. Go over and SPF fails for every message. - It checks the envelope, not the From line. SPF checks the hidden "bounce" address (the Return-Path), not the From address you see. On its own it doesn't stop someone faking the visible sender. That's one of the gaps DMARC fills.
- Forwarding breaks it. When a message is forwarded, it arrives from the forwarding server, which isn't on your list.
DKIM: a signature that proves nothing changed
DomainKeys Identified Mail adds a digital signature to every message you send. Your mail system signs each message with a private key that only it holds, and you publish the matching public key in DNS. The receiving server uses the public key to check the signature. If the message was tampered with on the way, or wasn't signed by you, the check fails.
The public key lives at a name like selector1._domainkey.example.com. The "selector" lets you have
several keys at once, one for each service that sends for you, and change them without downtime.
Unlike SPF, DKIM survives forwarding, because the signature travels with the message. You don't usually write DKIM records yourself: each email service generates the key and tells you which record to add.
- Microsoft 365: in the Defender portal, under Email authentication settings, you add two
CNAMErecords (selector1andselector2) and then switch signing on. - Google Workspace: in the Admin console, under Gmail → Authenticate email, you generate a key
and add it as a
TXTrecord, usually atgoogle._domainkey. - Newsletter and helpdesk services: look for "domain authentication" or "sender authentication" in their settings; they'll give you the records to add.
DMARC: the policy that ties it together
Domain-based Message Authentication, Reporting and Conformance does three jobs:
- It checks the From address you can see. A message only passes DMARC if SPF or DKIM passes for the same domain as the From address. This is called alignment, and it's what finally stops someone faking your visible address.
- It sets a policy. You tell receiving servers what to do with messages that fail:
none(just report),quarantine(send to spam) orreject(block). - It sends you reports. Receivers like Google and Microsoft send daily summaries showing every server that sent email claiming to be you, and whether it passed. This is how you find the forgotten services that still need setting up.
A DMARC record goes at _dmarc.example.com and looks like this:
v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com
Do I really need all three?
For any domain that sends email, yes. They work as a set: SPF and DKIM do the checking, and DMARC decides what happens and reports back.
The big email providers now insist on it for anyone sending in volume. Since February 2024, Gmail and Yahoo require SPF, DKIM and DMARC from domains sending 5,000 or more messages a day to their users, and Microsoft added the same requirement for Outlook.com, Hotmail and Live addresses in May 2025. Smaller senders aren't formally required to have all three yet, but mail without them is treated with more suspicion, so it's far more likely to end up in spam.
Setting them up, in a safe order
- List everything that sends email as your domain. Your mailboxes, plus anything else: website forms, invoicing or accounts software, newsletters, CRM, helpdesk, scanners and printers that email, and any supplier that sends "on your behalf".
- Publish one SPF record covering all of them. Our SPF & DMARC
Builder lets you tick the services you use, counts the lookups, and can load your current record so you edit
rather than start again. Start with
~all(soft fail) if you're not sure you've found everything. - Switch on DKIM at each service that supports it, adding the records each one gives you.
- Publish DMARC with
p=noneand an address for reports. Nothing changes for your email at this stage; you're only watching. - Read the reports for two to four weeks. They arrive as XML attachments, which free DMARC report tools turn into readable summaries. Fix anything genuine that's failing.
- Tighten the policy: move to
p=quarantine, thenp=reject. You can usepct=to apply it to a percentage of failing mail first.
DNS changes usually take effect within an hour; the DNS Propagation Checker shows when the big providers have picked them up.
Checking it works
- Check your records: the Email Health checker looks up SPF, DKIM and DMARC for any domain and flags common mistakes like two SPF records or too many lookups.
- Check a real message: send yourself an email at a Gmail or Outlook.com address, copy its headers, and paste them into the Email Header Analyser. It shows whether SPF, DKIM and DMARC actually passed, and which domain each one checked.
Common mistakes
- Two SPF records. Merge them into one; never add a second.
- Forgetting a sender. The accounts system or website form that suddenly lands in spam after
you switch DMARC to reject. That's what the
p=nonestage and the reports are for. - Jumping straight to
reject. Tempting, but it can silently block your own legitimate email. - Using
+allin SPF. It means "anyone may send as us", which defeats the point. - No report address. DMARC without
rua=gives you no visibility at all. - Leaving parked domains unprotected. A domain that never sends email should have
v=spf1 -alland a DMARC policy ofp=reject, or scammers can use it freely.