Setting up SPF, DKIM and DMARC for Microsoft 365 (Exchange Online): step by step
Complete email authentication for Microsoft 365: the SPF record at your DNS provider, creating DKIM in the Defender portal, publishing the CNAMEs and switching it on, setting DMARC — with the two typical Exchange Online traps.
For Microsoft 365 you set SPF and DMARC at your domain's DNS provider (there is no portal for that in Microsoft 365), but DKIM in the Microsoft Defender portal: security.microsoft.com/authentication → "DKIM" tab → domain → "Create DKIM keys" → publish the two CNAMEs shown in DNS → switch on the toggle "Sign messages for this domain with DKIM signatures". The basic SPF record is suggested during domain setup; DKIM and DMARC remain manual work — and that is exactly where the two traps we see most often in practice are hiding.
Step 1: SPF at the DNS provider
Microsoft states it explicitly: for SPF there is neither an admin portal nor a PowerShell cmdlet — the TXT record is created at the registrar or DNS hoster (e.g. World4You, Strato, IONOS). Microsoft recommends -all because DMARC handles the rest:
your-domain.comv=spf1 include:spf.protection.outlook.com -allStep 2: Create DKIM in the Defender portal
- In the Defender portal https://security.microsoft.com go to Email & collaboration → Policies & rules → Threat policies → Email authentication settings — or open https://security.microsoft.com/authentication directly.
- Select the "DKIM" tab and click your own domain.
- At the bottom of the details flyout click "Create DKIM keys" — Microsoft then shows the two CNAME records under "Publish CNAMEs".
- Create both CNAMEs at your DNS provider (host names selector1._domainkey and selector2._domainkey, targets copied exactly from the portal).
- After a while, return to the portal and switch on the toggle "Sign messages for this domain with DKIM signatures". Only then is DKIM active.
selector1._domainkey.your-domain.comselector1-your-domain-com._domainkey.yourtenant.r-v1.dkim.mail.microsoftselector2._domainkey.your-domain.comselector2-your-domain-com._domainkey.yourtenant.r-v1.dkim.mail.microsoftStep 3: DMARC at the DNS provider
Microsoft does not create DMARC for you. The TXT record under _dmarc goes to the DNS provider like SPF — first with p=none and a reporting address, read reports for a few weeks, then via quarantine to reject (step-by-step plan). Microsoft itself recommends quickly setting DKIM and DMARC in monitoring mode in complex environments, because the reports reveal the forgotten senders:
_dmarc.your-domain.comv=DMARC1; p=none; rua=mailto:dmarc@your-domain.comStep 4: Check
After switching on, send an email to a Gmail mailbox and open "Show original" there: spf=pass, dkim=pass with your domain, dmarc=pass is the goal. Or check the domain here — then you also see whether both selectors can be found. In the Defender portal the domain's status must be "Valid"; "CnameMissing" means a CNAME is missing or not yet propagated.
Frequently asked questions
Where do I find the DKIM setting for Exchange Online?
In the Microsoft Defender portal at https://security.microsoft.com/authentication, "DKIM" tab (menu path: Email & collaboration → Policies & rules → Threat policies → Email authentication settings). Click the domain there, "Create DKIM keys", set the CNAMEs, switch on the toggle.
Does the onmicrosoft.com domain also need to be secured?
Microsoft signs and authenticates the default domain itself; you cannot even change its SPF. What matters is that your users send with your own domain — mail from the onmicrosoft address quickly looks unprofessional to recipients.
My CNAME targets end in onmicrosoft.com, the guide shows dkim.mail.microsoft — which is right?
Both exist: older tenants use targets on …onmicrosoft.com, newer ones the pattern …<letter>-v1.dkim.mail.microsoft. What counts is always what the Defender portal shows for your domain — enter exactly that.
We also use an upstream mail filter — does that change anything?
For OUTBOUND sending through the filter, its path must be in SPF and ideally signed with its own DKIM. Such chains (filter in front of Exchange) are error-prone — this is where a professional's look at the actual mail flow pays off.