How to set up SPF, DKIM and DMARC for Microsoft 365
A domain that sends mail through Microsoft 365 needs three things in DNS: one SPF TXT record that lists every service allowed to send as you, two DKIM CNAME records with signing switched on in the Microsoft Defender portal, and a DMARC TXT record at _dmarc that tells receivers what to do with mail that fails both. Add them in that order, start DMARC at p=none so you only collect reports, and move to p=quarantine and then p=reject once the reports show your real senders passing.
The record syntax is the easy part. The work is finding everything else that sends as your domain — the newsletter tool, the accounting system that emails invoices, the website contact form, the office copier — because those are what bounce when DMARC starts enforcing.
First: list everything that sends as your domain
Before changing any record, write down every system that puts your domain in the From address. In a typical small organization that is:
- Microsoft 365 itself (people's mailboxes, shared mailboxes, Teams and SharePoint notifications).
- A newsletter or marketing tool, a CRM, a helpdesk, a donation or booking platform.
- Accounting or invoicing software that emails customers "from" you.
- The website: contact forms, order confirmations, password resets.
- Copiers, scanners and line-of-business apps that send alerts or scan-to-email.
Each third-party service publishes the SPF include or DKIM records it needs in its own help pages, usually under "domain authentication" or "sender authentication". Collect them now. A sender you miss at this stage is the one that stops delivering when you reach p=reject.
To see the records Microsoft expects for a domain, go to the Microsoft 365 admin center → Settings → Domains, select the domain and open the DNS records tab.
SPF: one record, ending in -all
SPF is a single TXT record at the root of the domain listing who may send for it. If Microsoft 365 is the only sender:
v=spf1 include:spf.protection.outlook.com -all
Every other sender goes into that same record — for example v=spf1 include:spf.protection.outlook.com include:servers.example-mailer.com -all. A device or app that sends straight from your office's public IP address, rather than signing in to Microsoft 365, needs that address added as ip4:203.0.113.10.
The rules that catch people out:
- Only one SPF record per domain. When a vendor's setup page says "add this SPF record", merge its include into your existing one. Two records starting with
v=spf1make SPF fail with a permanent error for every message. - Ten DNS lookups, maximum. Each
include:,a,mx,existsandredirectcosts a lookup, and nested includes count too. Over ten, SPF fails with a permanent error.ip4:andip6:entries are free. - End with
-all. Microsoft recommends hard fail for Microsoft 365 domains.?allmeans "no opinion" and protects nothing;+alllets anyone on the internet send as you. - Subdomains need their own record. The SPF record for
example.orgdoes not covernews.example.org. - Domains that never send mail should publish
v=spf1 -all, so nobody can use them for spoofing.
DKIM: two CNAMEs, then switch signing on
Microsoft 365 already signs mail from your initial .onmicrosoft.com domain. For each custom domain you send from, you publish two CNAME records and then enable signing.
- Open the Microsoft Defender portal → Email & collaboration → Policies & rules → Threat policies → Email authentication settings, and select the DKIM tab. The direct link is
https://security.microsoft.com/authentication?viewid=DKIM. - Find the domain. If its status is NoDKIMKeys, slide its toggle towards Enabled. The portal generates keys, shows an error listing the CNAME values it needs, and the status changes to CnameMissing.
- Click the domain row (not the checkbox) to open the details flyout and copy the two values under Publish CNAMEs.
- At your DNS host, create two CNAME records with the hostnames
selector1._domainkeyandselector2._domainkey, pointing at the values you copied. Set the TTL to at least one hour. - Back in the flyout, switch Sign messages for this domain with DKIM signatures on. Once Microsoft detects the records, the status reads Signing DKIM signatures for this domain.
Always copy the targets from the portal. Domains added from May 2025 use a newer format ending in dkim.mail.microsoft, older ones end in onmicrosoft.com, and the values are specific to your tenant.
The same thing in Exchange Online PowerShell:
Connect-ExchangeOnline
# Create keys without enabling signing yet
New-DkimSigningConfig -DomainName example.org -Enabled $false
# The two CNAME targets to publish
Get-DkimSigningConfig -Identity example.org |
Format-List Name, Enabled, Status, Selector1CNAME, Selector2CNAME
# After the CNAMEs are live
Set-DkimSigningConfig -Identity example.org -Enabled $true
If the status stays at CnameMissing, the usual causes are the domain typed twice into the hostname (selector1._domainkey.example.org.example.org), a TXT record created instead of a CNAME, or Cloudflare's proxy left on for the record — DKIM CNAMEs must be DNS-only. DNS changes can take up to 48 hours to be seen.
DMARC: start at p=none, finish at p=reject
DMARC is a TXT record at _dmarc.yourdomain. It tells receivers what to do when a message fails both SPF and DKIM alignment, and where to send daily reports. Start in monitoring mode:
Host: _dmarc
Type: TXT
Value: v=DMARC1; p=none; rua=mailto:dmarc-reports@example.org
The reports arrive as XML attachments, one per receiving provider per day. They list every IP address that sent mail claiming to be your domain and whether it passed SPF and DKIM. Read them for two to four weeks. Anything legitimate that fails needs fixing at the sender — an SPF include, or better, DKIM signing with your domain, which most mail platforms support.
Then tighten in steps:
v=DMARC1; p=quarantine; pct=25; rua=mailto:…— a quarter of failing mail goes to junk. Raisepctto 50, 75, then 100 as the reports stay clean.v=DMARC1; p=reject; rua=mailto:…— failing mail is refused outright. Leaving outpctmeans 100%.
Two more records worth adding while you are there:
- Domains you own but never send from:
v=DMARC1; p=reject;straight away, alongsidev=spf1 -all. Do not publish DKIM records for them. - Your
.onmicrosoft.comdomain, if nobody sends from it: Microsoft 365 admin center → Settings → Domains → select the.onmicrosoft.comdomain → DNS records → Add record, type TXT, name_dmarc, valuev=DMARC1; p=reject.
A DMARC record on the parent domain also covers subdomains that do not have their own _dmarc record, including ones that do not exist — which is what stops someone sending as billing.example.org.
What breaks, and when
SPF and DKIM on their own rarely stop anything being delivered. DMARC enforcement is the step that does, so this list is mostly about the move from p=none to quarantine and reject:
- Third-party senders using their own domain behind the scenes. A newsletter tool can pass SPF for its domain and still fail DMARC for yours, because the domains do not match. Turn on the service's custom DKIM or "authenticated domain" option so it signs as you.
- The copier and the line-of-business app. If they send directly from the office IP and that IP is not in SPF, their mail fails once DMARC enforces — and because no person is waiting on it, nobody notices until a scanned invoice never arrives.
- A second SPF record or an eleventh lookup. Either one fails SPF for all your mail, including Microsoft 365's. If DKIM is also missing, DMARC fails everything at once.
- Forwarding and mailing lists. Messages forwarded through another system can lose their SPF pass and sometimes break DKIM. This is normal and is a reason to have DKIM working before you enforce, since DKIM survives plain forwarding where SPF does not.
And the reason not to stop at p=none: it protects nothing. Spoofed mail using your domain is delivered exactly as before; you are only being told about it. Separately, Gmail and Outlook.com now require anyone sending around 5,000 or more messages a day to their users to have SPF, DKIM and at least a p=none DMARC record, and Yahoo has similar bulk-sender rules, so missing records increasingly affect whether your own mail lands.
Checking it worked
From any Windows machine, these read the published records directly:
Resolve-DnsName example.org -Type TXT | Where-Object { $_.Strings -match 'v=spf1' }
Resolve-DnsName _dmarc.example.org -Type TXT
Resolve-DnsName selector1._domainkey.example.org -Type CNAME
Resolve-DnsName selector2._domainkey.example.org -Type CNAME
Then send a message from a Microsoft 365 mailbox to an outside address, open the message headers, and find Authentication-Results. You want spf=pass, dkim=pass and dmarc=pass, with header.d= showing your own domain rather than onmicrosoft.com.
A published DKIM CNAME is not the same as signing being on. Public DNS shows the records exist; only the DKIM tab in the Defender portal, or Get-DkimSigningConfig, shows whether Microsoft is actually signing with them. Check both.
Questions
Do I need DMARC if I already have SPF and DKIM?
Yes. SPF and DKIM only produce a pass or fail. DMARC is the record that tells receivers to junk or reject mail that fails, and it checks that the passing domain matches the From address people actually see. Without it, a spoofed message can still be delivered.
Should my SPF record end in -all or ~all?
Microsoft recommends -all for Microsoft 365 domains. Soft fail (~all) is weaker, and ?all gives no protection at all. Whichever you choose, DMARC at quarantine or reject is what actually stops spoofed mail being delivered.
Why does DKIM stay at CnameMissing?
Microsoft has not found the two CNAME records yet. Check that the hostnames are just selector1._domainkey and selector2._domainkey without your domain added twice, that they are CNAME rather than TXT records, and that any Cloudflare proxy is off for them. Allow up to 48 hours for DNS to update.
How long should DMARC stay at p=none?
Long enough to see every legitimate sender in the reports passing, which is usually two to four weeks. Leaving it at p=none indefinitely is the most common outcome and protects nothing, because spoofed mail is still delivered.
Is this actually configured right in your tenant?
A read-only scan checks this and 27 other things in about a minute, and shows you your grade and every finding for free. The full report with named accounts, costs and fixes is $79.
Scan my tenant →Click paths verified October 2026. Microsoft renames things in the admin centers regularly; the underlying settings are stable even when the menus move.