SPF · DKIM · DMARC
Set up SPF, DKIM and DMARC on Microsoft 365
The DNS records that make Outlook and Gmail trust your Microsoft 365 mail — publish the SPF line, the two DKIM CNAMEs and DMARC, switch DKIM on in the Defender portal, then confirm it landed.
Before you start
What Microsoft 365 needs from your DNS.
Microsoft 365 sends your mail through Exchange Online, but receivers judge it on what your DNS says, not on the fact that Microsoft carried it. SPF authorises Microsoft's servers to send for you, DKIM signs each message so tampering shows, and DMARC ties both to the domain your recipients see and tells receivers what to do when they fail.
DKIM on a custom domain is not on by default. Microsoft generates two selector keys for you, but until you publish both CNAME records and slide the toggle to Enabled on the DKIM tab of the Defender portal, your mail from the custom domain is signed only by the shared *.onmicrosoft.com domain — which never aligns with your From address for DMARC. That missed toggle is the most common reason a Microsoft 365 domain fails DKIM alignment.
Since February 2024, Google and Yahoo require anyone sending in bulk to their users to publish SPF, DKIM and a DMARC record. On Microsoft 365, authenticating your custom domain is no longer good practice you can defer — it is the gate to your own recipients' inboxes.
The records to publish
Copy these into your DNS.
Add each record at your DNS provider — the company where your domain is registered, not Microsoft 365. Then run the checker to confirm every one resolves.
SPF record
v=spf1 include:spf.protection.outlook.com -all
One SPF record only. Microsoft recommends -all (hard fail) because you also run DKIM and DMARC. If other services send for you — a CRM, a newsletter tool — add their include: to this same line rather than publishing a second SPF record, which is a permerror that voids both.
DKIM selector 1 record
value generated by Microsoft 365
A CNAME, not a TXT. The target is generated per-domain — new domains get the selector1-<domain>._domainkey.<prefix>.<char>-v1.dkim.mail.microsoft format (since May 2025), older domains the selector1-<domain>._domainkey.<prefix>.onmicrosoft.com format. Copy the exact value from the DKIM tab in the Defender portal (security.microsoft.com); do not hand-type the dynamic character.
DKIM selector 2 record
value generated by Microsoft 365
The second selector, also a CNAME. Microsoft rotates signing between the two keys, so both records must exist even though only one signs at a time. Take its exact target from the same Publish CNAMEs panel in the Defender portal.
DMARC record
v=DMARC1; p=none; pct=100; rua=mailto:[email protected]
Start at p=none to watch who sends as you, then raise to quarantine and reject once your reports show every legitimate sender aligning. Point rua at a mailbox you actually read, not a personal inbox.
Step by step
The whole setup, in order.
- 1 Publish SPF at your DNS host. At your registrar or DNS provider — not in Microsoft 365 — add the TXT record above at the root of your domain. If an SPF record already exists, edit it to include spf.protection.outlook.com rather than adding a second one. Microsoft 365 has no portal for SPF; it lives entirely in your DNS.
- 2 Get the two DKIM CNAME targets from the Defender portal. Go to the DKIM tab of Email authentication settings at security.microsoft.com, select your custom domain, and read the required selector1 and selector2 CNAME values from the Publish CNAMEs panel. The targets differ per domain, so copy them exactly.
- 3 Publish both DKIM CNAME records. At your DNS host, add the two CNAME records at selector1._domainkey and selector2._domainkey pointing to the targets you copied. They are CNAMEs, not TXT records. Both are required even though Microsoft signs with one selector at a time.
- 4 Enable DKIM signing. Back on the DKIM tab, once the CNAMEs resolve, slide the toggle for your domain from Disabled to Enabled. Until you do, your custom domain is not DKIM signed and DMARC will not align. This is the click most people miss.
- 5 Publish DMARC. Add the _dmarc TXT record above at the root of your domain. Begin at p=none so you break nothing while you read the reports, and keep the rua address pointed at a monitored mailbox.
- 6 Wait, then verify. DNS and Microsoft can take time to detect the CNAMEs. Once they have, run a full check here to confirm SPF resolves under the 10-lookup limit, the selector1 CNAME is found and signing, and DMARC is graded.
Where it goes wrong
The mistakes specific to Microsoft 365.
Confirm it worked
Do not trust it until you have checked it.
DNS takes a few minutes to propagate. Once it has, run a full check: it reads all three records live, counts your SPF lookups, confirms the Microsoft 365 DKIM selector resolves, and grades your DMARC policy — the exact things that decide whether Gmail and Outlook trust your mail.
Common questions
About Microsoft 365, specifically.
Set it once. Know it stays set.
A DKIM key rotates, a vendor changes its SPF, an IP gets listed — and your carefully-configured domain quietly breaks. Monitoring watches all of it and tells you the day it changes.