SPF, DKIM and DMARC for Microsoft 365
Set up SPF and DKIM for a custom domain in Microsoft 365 and Exchange Online: the SPF include, the two DKIM CNAME records and their 2025 format, and where to switch signing on in Microsoft Defender.
Microsoft 365
staff mail
SPF
aligns: include:spf.protection.outlook.com in the domain's SPF record
DKIM
aligns after setup: off for custom domains until both CNAMEs are published and signing is enabled
DMARC pass
one aligned pass is enough
- TXT
@v=spf1 include:spf.protection.outlook.com -allAdd the include to the existing record if there is one: a domain has one SPF record. - CNAME
selector1._domainkeyselector1-<domain-with-dashes>._domainkey.<tenant>.<letter>-v1.dkim.mail.microsoftDomains added since May 2025. Older domains point at selector1-<domain-with-dashes>._domainkey.<tenant>.onmicrosoft.com instead. - CNAME
selector2._domainkeyselector2-<domain-with-dashes>._domainkey.<tenant>.<letter>-v1.dkim.mail.microsoft
1Add the SPF include
In the domain's DNS, make sure its one SPF record includes spf.protection.outlook.com. Microsoft recommends ending it with -all once DKIM and DMARC are in place.
2Read the two DKIM values
In the Microsoft Defender portal (security.microsoft.com), open Email & collaboration › Policies & rules › Threat policies › Email authentication settings › DKIM, and choose the custom domain, not the onmicrosoft.com one. Create DKIM keys if asked; the panel shows the two CNAME values. Get-DkimSigningConfig in Exchange Online PowerShell shows them too.
3Publish both CNAME records
selector1._domainkey and selector2._domainkey, pointing exactly at the values shown. Copy them rather than typing: the letter before -v1 differs between domains.
4Turn signing on
Back on the DKIM tab, switch Sign messages for this domain with DKIM signatures on. Microsoft detects the CNAMEs first; that can take a while after publishing.
5Publish a DMARC record
At _dmarc.<your domain>, a TXT record starting at p=none with a report address, so you can see this service's mail pass before you enforce. The DMARC generator writes one.
The free tools
Set up once. Watched every day.
DNS says what a domain asks receivers to do. Only the reports receivers send say what happened to its mail. DMARC Harbor reads those reports for every client domain, every day, names each service sending as it, and says when it is safe to move to p=reject.