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
-
Open the DKIM tab, or go to Email & collaboration > Policies & rules > Threat policies > Email authentication settings > DKIM.
-
In your domain's row, Status reads NoDKIMKeys. Slide Toggle to Enabled. A Client error dialog opens, as expected. Select OK.
-
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.
-
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._domainkeypoints toselector1-example-com._domainkey.example.n-v1.dkim.mail.microsoftselector2._domainkeypoints toselector2-example-com._domainkey.example.n-v1.dkim.mail.microsoft
These are examples. The
nis a character Microsoft assigns to each domain (for example,rorn), so copy the exact target from the flyout.exampleis your*.onmicrosoft.comprefix. Custom domains older than this May 2025 format keepselector1-example-com._domainkey.example.onmicrosoft.com.Caution: a name with a CNAME can hold no other record. If another service already signs with
selector1orselector2here, move it to another selector first, or you break its DKIM. -
Wait. Detection takes a few minutes or longer, and DNS propagation can take up to 48 hours.
-
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
- In Exchange Online PowerShell, run
Get-DkimSigningConfig | Format-List Name,Enabled,Status,Selector1CNAME,Selector2CNAME. - If your domain isn't listed, run
New-DkimSigningConfig -DomainName example.com -Enabled $falseand repeat step 1. - Publish the
Selector1CNAMEandSelector2CNAMEvalues as CNAME records, then runSet-DkimSigningConfig -Identity example.com -Enabled $true.
Confirm it worked
- The flyout shows Signing DKIM signatures for this domain, with the toggle Enabled and Rotate DKIM keys available. PowerShell shows Enabled
Trueand StatusValid. - 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). - Open the headers, or paste them into the email header analyzer.
DKIM-Signatureshould showd=example.com, andAuthentication-Resultsshould showdkim=passordkim=OK. - 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, creatingselector1._domainkey.example.com.example.com. Enter onlyselector1._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.comsignature 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-DkimSigningConfigdefaults to 1024, and RFC 8301 says signers should use at least 2048. RunRotate-DkimSigningConfig -Identity example.com -KeySize 2048, and again after that rotation ends, to cover both selectors.