SPF, DKIM and DMARC in Microsoft 365
Microsoft 365 only signs the onmicrosoft.com domain on its own. For your custom domain to pass DMARC you publish its SPF, create the DKIM keys in the Defender portal, publish the two CNAMEs it gives you and turn signing on. Then DMARC.
What to publish
@ (the domain)v=spf1 include:spf.protection.outlook.com -all
If Microsoft 365 is your only sender. If you also send from other services, add their include: before -all: one SPF record per domain and at most 10 DNS lookups. In GCC High or DoD, include:spf.protection.office365.us; with 21Vianet, include:spf.protection.partner.outlook.cn.
selector1._domainkeyThe one the Defender portal shows you, for example selector1-yourdomain-com._domainkey.yourcompany.n-v1.dkim.mail.microsoft (for domains set up long ago, it ends in onmicrosoft.com).
Do not type it by hand: every organisation has its own.
selector2._domainkeyThe second one the portal shows you (the same, with selector2).
Microsoft uses both to rotate keys.
_dmarcv=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com
Start at p=none with reports and move to quarantine and reject once all your legitimate mail passes (below).
Step by step
- At your DNS provider, publish the SPF record (or add
include:spf.protection.outlook.comto the one you have). - In the Microsoft Defender portal (security.microsoft.com), go to Email & collaboration > Policies & rules > Threat policies > Email authentication settings > DKIM tab (shortcut:
security.microsoft.com/authentication?viewid=DKIM). - Open your domain and press “Create DKIM keys”. The portal shows you the two CNAMEs: publish them as they are in your DNS.
- Once the CNAMEs resolve (it can take a while), go back to the domain and turn on “Sign messages for this domain with DKIM signatures”.
- Publish DMARC at
p=nonewith anruamailbox and read the reports for a few weeks before raising the policy.
Usual mistakes
- Two SPF records on the same domain: receivers treat both as invalid. Merge them into one.
include=instead ofinclude:, a space after the colon or a trailing dot after the domain.- Copying Microsoft’s IPs instead of the
include:: they change, and Microsoft asks you not to “flatten” it. - Publishing the DKIM CNAMEs and forgetting to turn signing on in the portal.
- If your DNS is on Cloudflare, the DKIM CNAMEs must be “DNS only” (grey cloud), not proxied.
Towards p=reject
DMARC at p=none only watches. The reports (rua) show who sends on your behalf; once all your legitimate mail passes aligned SPF or DKIM, move to quarantine and then to reject. That way, nobody can use your domain to send forged mail.
Check your domain
Sources
- Microsoft Learn — Set up SPF to identify valid email sources for your Microsoft 365 domain
- Microsoft Learn — How to use DKIM for email in your custom domain
Checked on 24 September 2026. Panels change: if something does not match, the provider’s documentation wins.