Guides / How to set up DKIM in Microsoft 365 for your own domain
How to set up DKIM in Microsoft 365 for your own domain
If you send cold email from Outlook or Exchange Online mailboxes on your own domain, DKIM may not be doing what you think. Until you turn on DKIM for that domain, Microsoft 365 signs outgoing mail with your tenant's onmicrosoft.com domain instead. The signature passes, but it doesn't match the domain in your From address, so it doesn't count toward DMARC. Your mail then depends on SPF alone, which is fragile. Here's how to set it up properly and check that it worked.
Why the default signing isn't enough
DMARC passes only when SPF or DKIM passes for a domain that matches (aligns with) the From address. Microsoft's default signature uses a domain like yourcompany.onmicrosoft.com, so for mail from you@yourcompany.com it passes DKIM but fails DKIM alignment. If SPF also breaks, for example because a forwarder or a new sending tool isn't in your SPF record, DMARC fails. See SPF and DKIM pass but DMARC fails for how alignment works.
Turning on DKIM for your own domain makes Microsoft sign with d=yourcompany.com, which aligns and gives DMARC a second way to pass.
Step 1: get your two CNAME records
Microsoft 365 DKIM uses two selectors, selector1 and selector2, so it can rotate keys: one is active while the other is ready for the next rotation. You publish both as CNAME records that point to keys Microsoft hosts.
- Open the Microsoft Defender portal and go to the DKIM tab of the email authentication settings (Email & collaboration, then Policies & rules, then Threat policies, then Email authentication settings).
- Select your custom domain. The details pane shows the two CNAME records to publish. You can also see them in Exchange Online PowerShell with
Get-DkimSigningConfig -Identity yourcompany.com | Format-List Name,Enabled,Selector1CNAME,Selector2CNAME. - Copy both values exactly. The targets are generated for your tenant, and Microsoft has used different target formats over time, so don't build them from an example in a blog post.
Step 2: publish the records at your DNS host
- Create a CNAME with host
selector1._domainkeypointing to the Selector1CNAME value, and another with hostselector2._domainkeypointing to the Selector2CNAME value. - Watch the host field. Many DNS panels add your domain automatically, so entering
selector1._domainkey.yourcompany.comcan createselector1._domainkey.yourcompany.com.yourcompany.com. Enter onlyselector1._domainkeyif the panel appends the domain. - If you use Cloudflare, set these CNAMEs to DNS only, not proxied, so lookups return the real record.
- Don't delete your SPF or DMARC records while you do this. DKIM is added alongside them.
Step 3: turn on signing
Back on the DKIM tab, select the domain and switch on signing for it (in PowerShell, Set-DkimSigningConfig -Identity yourcompany.com -Enabled $true). If you see an error saying the CNAME record does not exist for this config, Microsoft can't see your records yet. Check the host names for the doubled-domain mistake above, check that the targets match exactly, and try again after DNS has had time to update.
Step 4: confirm it works
- Run the free checker on your domain. It looks up common selectors including selector1 and selector2 and shows whether a DKIM key is found.
- Send a message from a Microsoft 365 mailbox on that domain to a Gmail or other outside inbox and open the original message. The DKIM-Signature header should show d=yourcompany.com and s=selector1 or s=selector2, and the Authentication-Results line should show dkim=pass for your domain. You can paste the headers into the email header checker to read them.
- Check that DMARC passes in the same headers. If it does, you can start thinking about a stricter DMARC policy.
If you send cold email through another tool
DKIM in Microsoft 365 only covers mail that Microsoft 365 sends. If you connect the mailbox to a cold email platform that sends through Microsoft (over the mailbox connection), the Microsoft signature applies. If the platform sends through its own servers instead, it needs its own DKIM record on your domain with its own selector, and its servers need to be in your SPF record or covered by aligned DKIM. Check with each tool, then re-run the checker. If mail still lands in spam after everything passes, read SPF, DKIM and DMARC pass but emails go to spam.
Frequently asked questions
Does Microsoft 365 sign my emails with DKIM by default?
Yes, but with your tenant's onmicrosoft.com domain, not your custom domain. That signature doesn't align with your From address, so it doesn't help DMARC pass. Turn on DKIM for the custom domain to fix that.
Why are there two selectors, selector1 and selector2?
So Microsoft can rotate DKIM keys. Only one is used to sign at a time, but both CNAMEs must exist so a rotation doesn't break signing.
Is my Microsoft 365 DKIM key 1024 or 2048 bits?
Microsoft lists 1024 as the default key size when DKIM is set up with New-DkimSigningConfig in PowerShell, and Rotate-DkimSigningConfig -KeySize 2048 moves a domain to a 2048-bit key. The free checker shows the length of the key behind selector1 and selector2.
What does "CNAME record does not exist for this config" mean?
Microsoft can't find the selector1 and selector2 CNAME records yet. Usually the host name is wrong (often the domain was added twice), the target doesn't match exactly, or DNS hasn't updated. Fix the records and try enabling again.
Do I need DKIM if SPF already passes?
It's strongly recommended. SPF breaks in common situations like forwarding, and DMARC only needs one aligned pass, so aligned DKIM is your backup. Gmail and Yahoo also expect bulk senders to have both.
How do I check which DKIM selector my emails use?
Open a sent message's original headers and find the DKIM-Signature line. The s= value is the selector and d= is the signing domain. For Microsoft 365 custom-domain signing it will be selector1 or selector2.
Related guides
- SPF record for Microsoft 365 (Office 365): the exact value and common mistakes
- DKIM selector not found in Google Workspace: how to fix it
- DKIM key length for cold email: 1024 vs 2048 bits
- SPF and DKIM pass but DMARC fails: how alignment works and how to fix it
- DMARC policy for cold email: what to publish and when
- Outlook 550 5.7.515 access denied: what it means and how to fix it
- All guides
- Monitoring plans