SPF, DKIM and DMARC explained, with a step-by-step setup
What SPF, DKIM and DMARC each prove, the three DNS records for Google Workspace or Microsoft 365, and how to move DMARC from p=none to reject safely.
- By
- VerifyNGN team
- Reviewed by
- VerifyNGN team (fact-checked 2026-11-30)
- Published
SPF lists the servers allowed to send mail for your domain, DKIM signs each message with a key published in your DNS, and DMARC tells receivers what to do when a message claiming to be from you passes neither in a way that matches the From address. All three are TXT or CNAME records at your DNS host: a few records to type, then a wait while DNS and the providers catch up.
Gmail and Yahoo require all three from bulk senders, and Gmail requires SPF or DKIM from everyone (the Gmail and Yahoo checklist has the details). This guide explains what each record proves, gives the records Google Workspace and Microsoft 365 publish in their own docs, and shows how to move DMARC from monitoring to enforcement without blocking your own mail.
Check yours first: the DMARC checker reads a domain's SPF, DKIM and DMARC records and explains every problem in plain words; the Gmail and Yahoo sender check lists what DNS can and can't show against the providers' rules.
What each one proves
| Record | Where it lives | What it proves | The standard |
|---|---|---|---|
| SPF | A TXT record on the domain, starting v=spf1 | The server that handed over the message is allowed to send for the envelope sender's domain (the MAIL FROM, not the From you see) | RFC 7208 |
| DKIM | A TXT record (or a CNAME to one) at <selector>._domainkey.<domain> | The message was signed by the domain in the signature's d= and wasn't changed on the way | RFC 6376 |
| DMARC | A TXT record at _dmarc.<domain>, starting v=DMARC1 | The domain in the From header matches a domain that passed SPF or DKIM ("alignment"), and what the owner wants done when it doesn't | RFC 9989, which replaced RFC 7489 in May 2026 |
The gap DMARC closes: SPF and DKIM each check *a* domain, not necessarily the one in the From line. A message can pass SPF for a sending service's bounce domain and still show your name. Microsoft's DMARC page puts it plainly: a message passes DMARC if the SPF or the DKIM check passes *and* aligns with the From domain, and fails if both fail.
Before you start
Write down every service that sends mail with your domain in the From address: your mailbox provider, your newsletter or marketing tool, your cold email tool, your CRM, your help desk, invoices from your billing system. Each one needs to be in SPF, or sign DKIM with your domain, or both. A service you forget is the one DMARC will later flag.
Microsoft also recommends sending bulk mail from services you don't control from a subdomain (for example news.example.com), so a problem there doesn't affect the reputation of your staff's own mail.
Step 1: SPF
Publish one TXT record on the domain. The records the providers give for a domain that sends only through them:
Google Workspace: v=spf1 include:_spf.google.com ~all
Microsoft 365: v=spf1 include:spf.protection.outlook.com -all
Add an include: for each other sending service (its docs give the value), before the all at the end. Three rules:
- One record only. RFC 7208 says a domain with more than one SPF record produces a
permerror, and Microsoft's page says the same: merge them into one. - At most 10 DNS lookups.
include,a,mx,ptr,existsandredirecteach cost a lookup, and nested includes count too; past 10, the check fails with apermerror(RFC 7208, section 4.6.4).ip4:andip6:cost nothing. - End with
~allor-all.~allis a "softfail" ("probably not authorized"),-alla "fail". Google's page recommends~all; Microsoft's recommends-allfor Microsoft 365 domains, because DMARC then decides what happens. Microsoft notes that DMARC can't act on a~allfailure when the message has no DKIM signature, which is why it recommends-all. Never+all, which authorizes every server on the internet.
Step 2: DKIM (then a wait)
DKIM keys are made by whoever sends the mail, so you turn it on there and publish what it gives you.
Google Workspace. In the Admin console, go to Apps > Google Workspace > Gmail > Authenticate email, choose the domain and Generate New Record. Google recommends a 2048-bit key (1024 only if your DNS host can't hold a longer one); the default selector is google. Publish the TXT record it shows at your DNS host, then come back and click Start authentication. Google's page says to allow up to 48 hours for DKIM to start working.
Microsoft 365. In the Microsoft Defender portal, go to Email & collaboration > Policies & rules > Threat policies > Email authentication settings, open the DKIM tab and select your domain. Microsoft 365 uses two CNAME records, selector1._domainkey and selector2._domainkey, pointing at keys Microsoft holds; the portal shows the exact values for your domain. Create both at your DNS host, wait for the portal to detect them, then turn on Sign messages for this domain with DKIM signatures.
Every other sending service (newsletter, CRM, cold email tool) has its own DKIM setting: look for "authenticate your domain" or "custom DKIM" in its settings. Without it, the service may sign with its own domain, which doesn't align with yours.
Key length matters to the mailbox providers: Google's sender guidelines require at least 1024-bit keys to send to personal Gmail accounts and recommend 2048, and Yahoo's page recommends a minimum 1024-bit key.
Step 3: DMARC
Publish one TXT record at _dmarc.example.com. Start in monitoring mode, with an address for the daily reports:
v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com
p=is the policy:none(only report),quarantine(treat as suspicious, for example the spam or Junk folder) orreject.rua=is where receivers send aggregate reports. Without it, RFC 9989 says receivers must not send any, and you fly blind. Use a shared mailbox or a reporting service, not a person's inbox.adkim=andaspf=set alignment to relaxed (r, the default:mail.example.comaligns withexample.com) or strict (s). Leave them out unless you have a reason.
Google's page says to wait 48 hours after setting up SPF or DKIM before turning DMARC on.
Step 4: from p=none to reject (the part that takes time)
A DMARC record at p=none blocks nothing; it only gets you reports. Gmail's bulk sender rules accept p=none, but a domain anyone can spoof is still a domain anyone can spoof. Microsoft's rollout, in its own words a "gradual approach":
p=noneand read the reports. Each one lists the IP addresses sending as your domain and whether SPF and DKIM passed and aligned. Fix every legitimate source that fails (for example, a service signing DKIM with its own domain).p=quarantineonce the reports show your real mail passing.p=reject, Microsoft's goal, once quarantine has run without your own mail failing. RFC 9989 is more cautious: if your users post to mailing lists, it says not to publishp=reject; if you do, runp=nonefor at least a month andp=quarantinefor as long first.
Start with a low-volume subdomain and do the main domain last, as Microsoft suggests.
A note on pct
Older guides, and Google's and Microsoft's pages today, roll out with pct= (pct=10, pct=25... the share of failing mail the policy applies to). RFC 9989 made pct historic: it says the tag "was usually not accurately applied" unless it was 0 or 100, and it adds a test-mode tag instead: t=y asks receivers to apply one level less than the policy (quarantine acts like none, reject like quarantine). Receivers move to a new standard at their own pace, so a record with pct=100 does no harm; just don't count on fractions between 0 and 100.
Common mistakes
- Two SPF records after adding a new service: merge them.
- More than 10 lookups from stacking includes: remove services you no longer use, or move a sender to a subdomain.
- A service that signs DKIM with its own domain. SPF and DKIM both pass in the headers, DMARC still fails. Turn on custom DKIM at that service.
- Jumping straight to
p=rejectwithout reading at least a month of reports (RFC 9989's minimum): your invoices or support replies may be the mail that disappears. - Forgetting parked domains. A domain you own but never send from can be spoofed too. Microsoft's pages give
v=spf1 -allandv=DMARC1; p=reject;for them.
Check it worked
- Run the domain through the DMARC checker: it reads the SPF record and counts its lookups, tries common DKIM selectors (or the one you give it) and reads the key's length, and parses the DMARC policy and report address.
- Send a message to a Gmail account, open Show original and find the Authentication-Results header: you want
spf=pass,dkim=passanddmarc=pass. - Walk the whole list with the Gmail and Yahoo sender check, which also lists the rules DNS can't show (one-click unsubscribe, spam rate).
Authentication is half of it
Good records tell receivers the mail is really yours. They don't stop a message to an address that doesn't exist from bouncing, and the mailbox providers judge both. Before a campaign, remove the addresses that won't take mail: upload the list and get each address back with its status and what to do, or check one with the free email checker.