Skip to content
email By Peter Mastras 14 May 2026 9 min read

Setting up DKIM in Microsoft 365: what the documentation misses

Set up DKIM in Microsoft 365 / Office 365: publish the two CNAME records and enable signing. DKIM is off by default and fails silently — here's the fix.

Microsoft 365 doesn’t enable DKIM for custom domains by default. Until you explicitly set it up, your outbound mail is signed with Microsoft’s default key — using onmicrosoft.com as the signing domain. That means your DMARC alignment will either rely entirely on SPF, or fail for messages forwarded by other servers.

Here’s how to set it up correctly, and what goes wrong.

How to set up DKIM in Microsoft 365 (quick answer)

To enable DKIM for a custom domain in Microsoft 365 (Office 365):

  1. In Microsoft 365 Defender (security.microsoft.com) → Email & collaboration → Policies & rules → Threat policies → DKIM, select your domain and copy the two CNAME records it shows.
  2. Publish both CNAME records (selector1._domainkey and selector2._domainkey) at your DNS provider. The target uses hyphens, not dots — company.com.au becomes company-com-au.
  3. Wait for DNS propagation, then return to the DKIM page and click Enable. Publishing the records alone does not turn DKIM on — this activation step is the one Microsoft’s docs bury.
  4. Send a test email and confirm the header shows d=yourdomain.com (not onmicrosoft.com).

The rest of this guide explains why the default signing domain fails DMARC, and the errors that trip people up along the way.

Why the default signing domain is a problem

When DKIM isn’t configured for your custom domain, Microsoft signs outbound mail with a key tied to your tenant.onmicrosoft.com domain — not your actual From address domain.

DMARC alignment requires that the DKIM signing domain matches (or is organisationally related to) the From address domain. If you send from user@company.com.au but the DKIM signature is for company.onmicrosoft.com, DMARC passes only if SPF alignment also passes.

The failure case that matters: forwarded email. When a message is forwarded, the return-path (envelope sender) changes, which breaks SPF alignment. At that point, DKIM is your only path to DMARC alignment — and if it’s signed for the wrong domain, DMARC fails.

Setting up DKIM for your custom domain also makes your mail more resistant to false-positive filtering at large receiving providers.

What the setup actually involves

DKIM in Microsoft 365 uses two CNAME records in your DNS that point to keys Microsoft manages. The CNAME approach means Microsoft can rotate the keys without requiring you to change your DNS records each time.

The records look like:

selector1._domainkey.yourdomain.com  CNAME  selector1-yourdomain-com._domainkey.yourtenant.onmicrosoft.com
selector2._domainkey.yourdomain.com  CNAME  selector2-yourdomain-com._domainkey.yourtenant.onmicrosoft.com

The target hostname uses hyphens instead of dots in your domain name — company.com.au becomes company-com-au in the CNAME target. Get that transformation wrong and the CNAME resolves to nothing.

Step by step

1. Get the exact CNAME values from the admin centre

Don’t try to construct the CNAME targets manually. Go to Microsoft 365 Defender (security.microsoft.com) → Email & collaboration → Policies & rules → Threat policies → DKIM. Select your domain. Microsoft shows you the exact CNAME records to publish.

If you have multiple custom domains, each needs its own pair of CNAME records.

2. Publish the CNAME records in your DNS

Add both CNAME records at your DNS provider. The TTL doesn’t matter much — 3600 (1 hour) is fine.

Wait for propagation. You can verify with:

nslookup -type=CNAME selector1._domainkey.yourdomain.com

It should return the onmicrosoft.com target. If it returns NXDOMAIN, the records aren’t published or haven’t propagated yet.

3. Enable DKIM in the admin centre

This is the step the Microsoft documentation buries. Publishing the CNAME records alone doesn’t enable DKIM signing. You must return to the DKIM page in Microsoft 365 Defender, select your domain, and click Enable (or toggle it on).

After enabling, Microsoft runs a validation check against your CNAME records. If they’re not found, you’ll see an error — the most common being “CNAME record does not exist for this config.”

4. Verify it’s working

Send a test email to a Gmail address and check the message headers. Look for DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yourdomain.com. The d= domain should be your custom domain, not onmicrosoft.com.

The email auth checker will also show your DKIM selector status from a DNS perspective.

Enabling DKIM with PowerShell

If you manage Microsoft 365 from the command line — or you’re enabling DKIM across several tenants — Exchange Online PowerShell is faster than clicking through the portal.

Connect to Exchange Online:

Connect-ExchangeOnline -UserPrincipalName admin@yourdomain.com

Create the DKIM signing configuration for your domain. Create it disabled first, so you can read the CNAME targets and publish them before signing tries to start:

New-DkimSigningConfig -DomainName yourdomain.com -Enabled $false

Read the two CNAME records Microsoft expects you to publish:

Get-DkimSigningConfig -Identity yourdomain.com | Format-List Selector1CNAME, Selector2CNAME

Publish both CNAME records at your DNS provider, wait for propagation, then enable signing:

Set-DkimSigningConfig -Identity yourdomain.com -Enabled $true

Confirm the result:

Get-DkimSigningConfig -Identity yourdomain.com | Format-List Domain, Enabled, Status

Enabled should read True and Status should read Valid. If Status shows CnameMissing, the records haven’t propagated or were published incorrectly — the same root cause as the portal error below.

Rotating to a 2048-bit DKIM key

Microsoft 365 historically generated 1024-bit DKIM keys. 2048-bit is now the recommended standard and newer tenants get it by default, but a domain set up years ago may still be signing with a 1024-bit key. Check the key size in the DKIM signing config, and rotate if needed:

Rotate-DkimSigningConfig -KeySize 2048 -Identity yourdomain.com

Because the CNAME records point at keys Microsoft manages, you don’t republish DNS when a key rotates — Microsoft swaps the underlying key behind the existing selector. The one case that breaks rotation: if your DNS provider has dropped the CNAME records (some do silently on account or plan changes), the rotation has nothing to point at and signing fails. Confirm both selectors still resolve before and after any rotation.

What commonly goes wrong

“CNAME record does not exist for this config” — The most frequent error. Usually the CNAME records haven’t propagated yet — wait an hour and try again. If it persists after several hours, verify the records were published correctly. Check the exact hostname format (hyphens, not dots) and confirm both selector1 and selector2 records exist.

DKIM signing is enabled but DMARC still shows alignment failure — Check that d=yourdomain.com appears in the DKIM-Signature header, not a subdomain. If your From address is user@mail.company.com.au and you configured DKIM for company.com.au, you may have a subdomain mismatch with strict alignment mode. Relaxed alignment (the default) handles this — strict doesn’t.

DKIM enabled but emails still failing DMARC at some providers — Check whether the failing messages are forwarded. Forwarding strips SPF, so DKIM is the only remaining alignment mechanism. If DKIM was recently enabled, some providers may not have picked up the selector DNS record yet.

Key rotation failures — Microsoft rotates DKIM keys periodically. The CNAME approach should handle this transparently. If you see DKIM failures appearing after a period of correct operation, check whether your CNAME records still resolve correctly — occasionally DNS providers drop records on renewal.

After DKIM: the path to DMARC enforcement

Once DKIM is enabled and verified, check your DMARC aggregate reports. You should see dkim: pass appearing for messages sent through Microsoft 365. Once your reports show consistent alignment from all legitimate sending paths (not just M365 but also your CRM, marketing platform, and any other services), you can move DMARC from p=none toward p=quarantine and eventually p=reject.

If you’re reading p=none in your DMARC record and haven’t moved beyond it, the DMARC p=none explained article covers what that means and the checklist for moving to enforcement. If you’d rather have someone else own DKIM signing, DMARC enforcement and the ongoing monitoring, that’s what Mail Shield is for.

Sources

Frequently asked questions

Is DKIM enabled by default in Microsoft 365?
No. Microsoft 365 signs outbound mail with a default key tied to your tenant's onmicrosoft.com domain, but DKIM for your own custom domain stays off until you publish the two CNAME records and click Enable. Until then your DMARC alignment relies entirely on SPF, which breaks on forwarded mail.
How do I enable DKIM in Microsoft 365?
In Microsoft 365 Defender (security.microsoft.com), go to Email & collaboration, then Policies & rules, Threat policies, DKIM. Select your domain, publish the two CNAME records it shows at your DNS provider, then return and click Enable. Publishing the records alone does not turn signing on, the Enable step does.
Can I enable DKIM in Office 365 with PowerShell?
Yes. Connect with Connect-ExchangeOnline, create the config with New-DkimSigningConfig -DomainName yourdomain.com -Enabled $false, read the CNAME targets with Get-DkimSigningConfig, publish them in DNS, then run Set-DkimSigningConfig -Identity yourdomain.com -Enabled $true.
How long does DKIM take to work after setup?
Signing starts within a few minutes of clicking Enable. The only real delay is DNS propagation of the two CNAME records, usually under an hour but occasionally up to 24 hours depending on your DNS provider and the record TTL.
What are selector1 and selector2 in Microsoft 365 DKIM?
They are the two DKIM selectors Microsoft uses to sign your mail. Two exist so Microsoft can rotate signing keys without interruption, keeping one selector active while the other rotates. Both CNAME records must be published or signing fails for messages using the missing selector.
Do I still need DKIM if I already have SPF?
Yes. SPF breaks when mail is forwarded because forwarding changes the envelope sender. DKIM survives forwarding, so it is often the only mechanism keeping DMARC aligned for forwarded mail. Proper DMARC setup has both SPF and DKIM aligned.
Why does the DKIM CNAME target use hyphens instead of dots?
Microsoft encodes your domain in the CNAME target with hyphens, so company.com.au becomes company-com-au. It is just the format Microsoft expects. Copy the exact value from the DKIM page rather than building it by hand, or the record resolves to nothing.

Need help with your email infrastructure?

Talk to an engineer