Skip to content
iBlockSpam
DKIM by provider

DKIM record for Microsoft 365

Microsoft 365 (Office 365) signs mail from a custom domain once you publish two CNAME records, selector1._domainkey and selector2._domainkey, and turn signing on in the Microsoft Defender portal. Microsoft holds the private keys. Custom domains added from May 2025 point to a target ending in dkim.mail.microsoft; older custom domains point to onmicrosoft.com.

Record type
CNAME
Selectors
selector1, selector2
Private key held by
Provider (CNAME delegation)

The DNS records

Microsoft generates the targets for your tenant, so copy yours from the Defender portal or from Get-DkimSigningConfig. The examples use the custom domain contoso.com and the initial domain contoso.onmicrosoft.com.

Selector 1, custom domains added from May 2025

Type: CNAME · Host: selector1._domainkey

selector1-contoso-com._domainkey.contoso.n-v1.dkim.mail.microsoft

The letter before -v1 (here n) is a partition Microsoft assigns, such as n or r. You can't choose it, so copy it rather than guess.

Selector 2, custom domains added from May 2025

Type: CNAME · Host: selector2._domainkey

selector2-contoso-com._domainkey.contoso.n-v1.dkim.mail.microsoft

Selector 1, custom domains added before May 2025

Type: CNAME · Host: selector1._domainkey

selector1-contoso-com._domainkey.contoso.onmicrosoft.com

Existing custom domains keep this older format. Microsoft says the old and new formats can't coexist for the same selector.

Selector 2, custom domains added before May 2025

Type: CNAME · Host: selector2._domainkey

selector2-contoso-com._domainkey.contoso.onmicrosoft.com

Set it up and turn on signing

  1. In the Microsoft Defender portal, go to Email & collaboration > Policies & rules > Threat policies > Email authentication settings and open the DKIM tab.
  2. Select your custom domain. It shows the toggle as Disabled and the status NoDKIMKeys. Slide the toggle: a "Client error" dialog appears with the two CNAME values and the status becomes CnameMissing. The error is expected; it means the keys exist but DNS doesn't point to them yet.
  3. Open the domain's details, copy both values under Publish CNAMEs, and create the two CNAME records at your DNS host. Microsoft suggests a TTL of at least 3600 seconds.
  4. When DNS has updated (Microsoft allows anywhere from a few minutes to 48 hours), turn on Sign messages for this domain with DKIM signatures. The status should read "Signing DKIM signatures for this domain".
  5. In Exchange Online PowerShell, Get-DkimSigningConfig -Identity contoso.com | Format-List Selector1CNAME,Selector2CNAME shows the targets, and Set-DkimSigningConfig -Identity contoso.com -Enabled $true turns signing on.

DMARC alignment

Microsoft signs mail from your contoso.onmicrosoft.com domain automatically, but says no DKIM signing happens for custom domains until you set it up. Until then DMARC can only pass for contoso.com through SPF, which forwarding breaks. Once signing is on, signatures carry d=contoso.com and align with your From address. Every subdomain you send from needs its own DKIM configuration, and Microsoft advises against publishing DKIM records for parked domains that send no mail.

Key length and rotation

Microsoft's PowerShell reference gives 1024 bits as the default key size and supports 1024 or 2048 (RSA only; Ed25519 isn't supported). Rotate DKIM keys in the portal, or Rotate-DkimSigningConfig -Identity contoso.com -KeySize 2048, moves signing to the other selector. The new key starts signing after four days (96 hours), and you can't start another rotation until then. A new key size applies to the next selector at the first rotation, so rotate once after choosing 2048. Because both names are CNAMEs, rotation needs no DNS change, which is why a missing selector2 record breaks it. Microsoft notes there is currently no automatic rotation for the onmicrosoft.com domain.

Common mistakes

  • A TXT record instead of a CNAME. Microsoft lists TXT as not supported for these names; it doesn't publish a key for you to paste.
  • The full name in the host field. Enter selector1._domainkey only. Microsoft notes that most DNS hosts, GoDaddy among them, add your domain, so selector1._domainkey.contoso.com becomes selector1._domainkey.contoso.com.contoso.com. In Route 53, Microsoft says to end the target with a period.
  • Copying a target from an old guide. Domains added since May 2025 use dkim.mail.microsoft targets. Copy what the portal shows for your domain.
  • Cloudflare proxy left on. Set both CNAMEs to DNS only; a proxied record doesn't resolve to Microsoft's key.
  • Testing with an internal message. Microsoft doesn't add a DKIM signature when sender and recipient are in the same organization, so test by sending to an outside mailbox.

Check your Microsoft 365 DKIM key

The selector is filled in for you; add your domain. Free, reads public DNS only.

Frequently asked questions

Why does Microsoft 365 show a Client error when I turn on DKIM?

Because the CNAME records don't exist yet. Sliding the toggle creates the keys, shows the two values you need, and sets the status to CnameMissing. Publish both CNAMEs at your DNS host, wait for DNS to update, then turn signing on again.

Which Microsoft 365 DKIM target format applies to my domain?

Custom domains added from May 2025 use targets ending in dkim.mail.microsoft. Domains added earlier keep targets ending in onmicrosoft.com. Don't convert one into the other: copy what the Defender portal or Get-DkimSigningConfig shows for your domain.

Do I need to publish DKIM records for my onmicrosoft.com domain?

No. Microsoft signs mail from your contoso.onmicrosoft.com domain automatically and manages its keys. Only the custom domains you add need the two CNAMEs, and only the ones that actually send mail.

Does Microsoft 365 support 2048-bit DKIM keys?

Yes. Microsoft supports RSA keys of 1024 or 2048 bits, but not Ed25519. A switch to 2048 bits applies to the next selector at the next rotation, so rotate once after changing it and allow four days for the new key to start signing.

Sources

Checked against Microsoft 365's documentation on October 9, 2026. Providers change their setup screens; if yours differs, follow the values your admin console shows.

DKIM records for other providers

Compare every provider's selectors in one table · SPF record for Microsoft 365

Last updated