Skip to content
DMARC Pulse

Microsoft 365

Office 365 DKIM setup: enable signing in Microsoft 365

Office 365 DKIM setup: publish two selector CNAME records, turn on signing in the Microsoft Defender portal and confirm dkim=pass in a test message.

Before you start

Office 365 DKIM setup comes down to two CNAME records at your DNS host and one toggle in the Microsoft Defender portal. Microsoft 365 signs your initial *.onmicrosoft.com domain automatically. A custom domain needs these steps. Pair DKIM with SPF for Microsoft 365 and DMARC for Microsoft 365.

You need:

  • The domain already added to Microsoft 365. Each domain or subdomain that sends mail needs its own pair of records.
  • Access to the domain's DNS zone.
  • Access. With Unified RBAC, managing DKIM requires Core security settings (manage). Ask your administrator to grant access.

Steps

Set up DKIM for Office 365 in the Defender portal

  1. Open the DKIM tab, or go to Email & collaboration > Policies & rules > Threat policies > Email authentication settings > DKIM.

  2. In your domain's row, Status reads NoDKIMKeys. Slide Toggle to Enabled. A Client error dialog opens, as expected. Select OK.

  3. Status becomes CnameMissing. Click the row, away from the check box and toggle, to open the details flyout (a settings panel). Copy both values under Publish CNAMEs and leave the flyout open.

  4. At your DNS host, create two CNAME records (aliases from one DNS name to another). The selector in each name tells receivers which key to fetch. Enter the host name without your domain, paste each target from the flyout and set the TTL (cache lifetime) to 3600 seconds. For example.com:

    • selector1._domainkey points to selector1-example-com._domainkey.example.n-v1.dkim.mail.microsoft
    • selector2._domainkey points to selector2-example-com._domainkey.example.n-v1.dkim.mail.microsoft

    These are examples. The n is a character Microsoft assigns to each domain (for example, r or n), so copy the exact target from the flyout. example is your *.onmicrosoft.com prefix. Custom domains older than this May 2025 format keep selector1-example-com._domainkey.example.onmicrosoft.com.

    Caution: a name with a CNAME can hold no other record. If another service already signs with selector1 or selector2 here, move it to another selector first, or you break its DKIM.

  5. Wait. Detection takes a few minutes or longer, and DNS propagation can take up to 48 hours.

  6. Back in the flyout, select the Sign messages for this domain with DKIM signatures toggle, then OK in the dialog.

Caution: keep both records while signing is on. A verifier that finds no key record must return PERMFAIL, so at p=quarantine or p=reject mail that relies on DKIM can be quarantined or rejected.

DKIM for Office 365 with PowerShell

  1. In Exchange Online PowerShell, run Get-DkimSigningConfig | Format-List Name,Enabled,Status,Selector1CNAME,Selector2CNAME.
  2. If your domain isn't listed, run New-DkimSigningConfig -DomainName example.com -Enabled $false and repeat step 1.
  3. Publish the Selector1CNAME and Selector2CNAME values as CNAME records, then run Set-DkimSigningConfig -Identity example.com -Enabled $true.

Confirm it worked

  1. The flyout shows Signing DKIM signatures for this domain, with the toggle Enabled and Rotate DKIM keys available. PowerShell shows Enabled True and Status Valid.
  2. Email a mailbox outside your organization, such as outlook.com or gmail.com. Inside your organization Microsoft omits the signature, and you see dkim=none (message not signed).
  3. Open the headers, or paste them into the email header analyzer. DKIM-Signature should show d=example.com, and Authentication-Results should show dkim=pass or dkim=OK.
  4. Check both names with nslookup -type=CNAME selector1._domainkey.example.com, or test the key in the DKIM checker.

Common problems

  • Status stays at CnameMissing. Your DNS panel may have appended the domain, creating selector1._domainkey.example.com.example.com. Enter only selector1._domainkey. Amazon Route 53 needs a trailing dot on the target. In Cloudflare, set the record to DNS only, or verification fails.
  • A TXT record holds the key. Microsoft 365 doesn't support that. Confirm no other service uses it, delete it and create the CNAME.
  • DKIM passes but DMARC fails. The d= domain must align with the From domain. RFC 9989 accepts the same Organizational Domain (relaxed, the default) or an identical domain (strict). A *.onmicrosoft.com signature doesn't align with a custom domain, so enable DKIM for the domain in your From address.
  • Receivers report dkim=temperror. Microsoft links this to a low TTL. Raise both records to at least 3600.
  • The key is 1024 bits. New-DkimSigningConfig defaults to 1024, and RFC 8301 says signers should use at least 2048. Run Rotate-DkimSigningConfig -Identity example.com -KeySize 2048, and again after that rotation ends, to cover both selectors.

Check it now

Find and validate DKIM keys

Frequently asked questions

Does Office 365 sign email with DKIM by default?
Only for the initial *.onmicrosoft.com domain. A custom domain is not signed with that domain until you publish its two CNAME records and enable signing. Microsoft's articles differ on whether that mail carries an *.onmicrosoft.com signature or none, and neither case aligns with your From domain for DMARC.
Why does Microsoft 365 use CNAME records for DKIM instead of TXT?
The CNAME records hand key management to Microsoft, which also handles rotation. Microsoft 365 does not support publishing its DKIM key yourself in a TXT record.
How long does Microsoft 365 DKIM take to start working?
Microsoft says detection of the new CNAME records takes a few minutes or possibly longer, and DNS propagation can take up to 48 hours depending on your DNS provider and TTL. After you turn on signing, the status change can take several minutes to synchronize.
Do I need both selector1 and selector2?
Yes. Microsoft 365 signs with one selector at a time and uses the other during key rotation. Without selector2 you can't rotate DKIM keys.
Can I use a 2048-bit DKIM key in Microsoft 365?
Yes. Microsoft 365 supports RSA keys of 1024 or 2048 bits and does not support Ed25519 keys. Rotate-DkimSigningConfig with -KeySize 2048 changes the selector that is not active, so run it again after the first rotation finishes. Each rotation takes four days (96 hours).
Why is there no DKIM signature when I test between my own mailboxes?
Microsoft omits the signature when the sender and recipient are in the same domain, or in different domains controlled by the same organization. Send the test to an outside mailbox such as outlook.com or gmail.com.

Sources consulted

RFC 8301 §3.2: Key Sizes
checked 2026-11-09

Related pages

Keep it healthy

Know the moment something breaks

Point your DMARC reports to DMARC Pulse and see who sends email as your domain, what fails and why — with a calm alert when anything changes.

Free plan: 1 domain, no credit card.