• Home
  • Blog
  • DKIM Office 365 Setup: How to Enable DKIM in Microsoft 365

DKIM Office 365 Setup: How to Enable DKIM in Microsoft 365

by

Last Updated:
11 min read
DKIM Office 365 Setup: How to Enable DKIM in Microsoft 365

Key Takeaways

  • Microsoft 365 signs mail from your initial onmicrosoft.com domain automatically. Custom domains need manual setup: two CNAME records per domain, then enabling signing in Microsoft Defender.
  • Copy the CNAME values from the Defender portal or from Get-DkimSigningConfig. Don’t build them by hand, because the target format depends on when the domain was added.
  • New-DkimSigningConfig defaults to 1024-bit keys. Use -KeySize 2048 or change the size during a key rotation to move to 2048-bit.
  • To rotate keys, use the Rotate DKIM keys button or Rotate-DkimSigningConfig. The new key starts signing after 96 hours.
  • DKIM alone is not enough. Configure SPF and DMARC alongside it.

DKIM Office 365 setup is manual for custom domains. Microsoft 365 signs mail from your initial onmicrosoft.com domain by default, but mail sent from a custom domain such as contoso.com is not signed with that domain until you publish two CNAME records and turn signing on. Without a signature from your own domain, receivers can’t verify that your messages weren’t altered in transit, and DKIM can’t help you pass DMARC. 

This guide covers the Defender portal and PowerShell methods, key rotation and the move to 2048-bit keys, verification, and the errors that most often block setup. For the bigger picture, see our guide to DMARC for Office 365.

What Is DKIM and Why Does It Matter for Microsoft 365?

DomainKeys Identified Mail (DKIM) adds a cryptographic signature to outbound email. The sending system uses a private key to sign important header fields and the message body, and it stores the signature in the DKIM-Signature header. The matching public key is published in DNS (as CNAME records in Microsoft 365). The key lookup uses both s= and d=: the receiver queries <s>._domainkey.<d>. 

DKIM shows that the signed header fields and body were not changed after signing. Unsigned headers can change without breaking it, and the l= tag can leave part of the body unsigned. The RFC frames DKIM’s purpose as a domain claiming responsibility for the message. DMARC passes when either DKIM or SPF authenticates (a valid DKIM signature or an SPF pass) and aligns with the From domain. The DMARC policy states the domain owner’s preferred handling, but the receiving server makes the final decision. 

If you want the fundamentals first, read our DKIM guide.

ProtocolWhat it checksDNS record in Microsoft 365Protects against
SPFWhether the sending server is authorized for the MAIL FROM (envelope) or HELO domainTXT record listing authorized sendersUnauthorized servers sending with your domain as the envelope sender
DKIMWhether signed parts of the message were alteredTwo CNAME records per domainMessage tampering in transit
DMARCWhether SPF or DKIM passes and aligns with the From domain, plus the domain owner's preferred handling if neither doesTXT record with your policySpoofing of the From domain

How Microsoft 365 Handles DKIM

What Microsoft Handles Automatically

If you send only from your initial domain (for example, contoso.onmicrosoft.com), you don’t need to do anything: Microsoft signs those messages automatically. Keep in mind that Microsoft doesn’t rotate the keys for the onmicrosoft.com domain automatically. You can also customize signing for it in the Defender portal. See our guide to DMARC and DKIM for onmicrosoft.com domains.

What Requires Manual Setup

Every custom domain you send from needs its own DKIM configuration and its own pair of CNAME records. The same applies to each subdomain you send from, because Microsoft 365 requires a separate DKIM configuration for each one. Microsoft recommends using a subdomain (such as marketing.contoso.com) for services you don’t control, like bulk mailers, so their reputation doesn’t affect your main domain.

Don’t publish DKIM records for parked domains that never send email. With no public key in DNS, forged mail from those domains can’t pass DKIM validation.

The Two-Selector System

When you enable DKIM for a custom domain, Microsoft 365 generates two key pairs. The private keys are inaccessible to you, and your two CNAME records (selector1 and selector2) point to the matching public keys. Only one selector signs messages at a time. The other stays inactive until a future key rotation activates it. You still need both CNAME records in DNS, or rotation will fail. The s= value in the DKIM-Signature header tells you which selector signed a given message.

Prerequisites for DKIM Setup in Office 365

PrerequisiteDetails
Admin permissionsUse the least-privileged role that works. You need permission to manage Email authentication settings in Microsoft Defender and to run Exchange Online PowerShell. Check Microsoft's permissions documentation for the exact roles.
Domain added to Microsoft 365The custom domain or subdomain must already be added. In PowerShell, Get-AcceptedDomain confirms it.
DNS accessYou need to create CNAME records at your registrar or DNS host.
SPF and DMARCNot required for DKIM to work, but DKIM alone isn’t enough. Plan to set up SPF and DMARC as well.

How to Set Up DKIM in Office 365 (Step by Step)

Setup has three parts: get your CNAME values from Defender, publish them in DNS, and enable signing. The Defender interface changes often, so we checked every step below against Microsoft’s own article, Set up DKIM to sign mail from your cloud domain, on 26 November 2026.

Step 1: Get your DKIM CNAME Values in Microsoft Defender

1. Sign in to the Microsoft Defender portal at security.microsoft.com and go to Email & collaboration > Policies & rules > Threat policies > Email authentication settings. Or open the DKIM tab directly: security.microsoft.com/authentication?viewid=DKIM.

dkim office 365

Source: Official Microsoft guide

2. Select the DKIM tab and find your custom domain. A domain without keys shows the toggle as Disabled and the status NoDKIMKeys.

dkim office 365

Source: Official Microsoft guide

3. Slide the toggle to Enabled. This first attempt is expected to fail: a Client error dialog opens and lists the required CNAME values. Select OK.

4. The status changes to CnameMissing and the toggle stays Disabled. Select the domain’s row (anywhere except the checkbox or the toggle) to open the details flyout.

5. In the Publish CNAMEs section, copy both values using Copy.

dkim office 365

Source: Official Microsoft guide

You may also see a Create DKIM keys button at the bottom of the flyout. The toggle method above is the one Microsoft documents.

Step 2: Publish the Two CNAME records

Create two CNAME records at your DNS host. The hostnames are the same for every Microsoft 365 organization. The targets depend on the domain.

Domain typeHostnamePoints to (example for contoso.com)
New custom domains (format introduced May 2025)selector1._domainkeyselector1-contoso-com._domainkey.contoso.n-v1.dkim.mail.microsoft
selector2._domainkeyselector2-contoso-com._domainkey.contoso.n-v1.dkim.mail.microsoft
Existing custom domains (older format)selector1._domainkeyselector1-contoso-com._domainkey.contoso.onmicrosoft.com
selector2._domainkeyselector2-contoso-com._domainkey.contoso.onmicrosoft.com

In the newer format, contoso-com is your domain with dots replaced by dashes, contoso is the prefix of your initial onmicrosoft.com domain, and n (in this example) is a partition character that Microsoft generates, and it can differ between domains. You can’t configure it. The old and new formats can’t coexist for the same selector.

Copy the values from the portal or from PowerShell. Never build them by hand. To retrieve them:

Get-DkimSigningConfig -Identity contoso.com | Format-List Name,Enabled,Status,Selector1CNAME,Selector2CNAME

Before you save the records, check that:

  • The record type is CNAME, not TXT. Microsoft 365 doesn’t support a TXT record for DKIM.
  • The hostname is only selector1._domainkey or selector2._domainkey, with no domain suffix, because most DNS hosts append the zone automatically.
  • Both records exist, even though only one selector is active at a time.
  • The TTL is 3600 seconds (1 hour) or higher. Microsoft recommends 3600 as a minimum.

Microsoft 365 takes a few minutes, sometimes longer, to detect new CNAME records.

DNS Host Notes: Cloudflare, GoDaddy, Route 53

  • Cloudflare: Set both records to DNS only (gray cloud, proxy off). A proxied record returns Cloudflare IP addresses instead of the CNAME target, and verification fails. Set TTL to 1 hour.
  • GoDaddy: GoDaddy appends your domain zone to the Name field, so enter only selector1._domainkey. Don’t add a trailing dot to the value. Use a TTL of 1 hour.
  • Amazon Route 53: Paste the target value exactly as copied. Route 53 treats it as fully qualified, so a trailing dot is optional. Use a TTL of 3600. 

Step 3: Enable DKIM Signing

Return to the domain’s details flyout and slide Sign messages for this domain with DKIM signatures to Enabled. A dialog warns that it may take several minutes to synchronize the status change. Select OK. If Microsoft 365 detects both CNAME records, the toggle shows Enabled, the status reads “Signing DKIM signatures for this domain”, Rotate DKIM keys becomes available, and the Last checked date is newer than before.

StatusMeaningWhat to do
NoDKIMKeysNo keys saved for this domain yetStart at Step 1
CnameMissingMicrosoft 365 can’t detect the CNAME recordsCheck the records in DNS, then wait and try again
ValidSigning is enabled and workingVerify with a test message
Rotating keys (portal text)A key rotation is in progressWait for it to finish (96 hours)

If the toggle fails, the error shows the values Microsoft 365 expects. Compare them with your DNS records, check for typos in dashes, periods, and underscores, wait a while longer, and try again.

dkim office 365

Source: Official Microsoft guide

Step 4: Verify DKIM Is Working

Wait a few minutes after enabling, then send a message from your domain to an external mailbox such as Gmail or Outlook.com. Don’t use AOL for testing, because AOL may skip the DKIM check when SPF passes. In Gmail, open the message, select the three-dot menu, and choose Show original. Confirm that:

  • The DKIM-Signature header exists, and d= matches your custom domain.
  • The s= value shows the selector in use.
  • Authentication-Results includes dkim=pass.

You can also run your domain through the PowerDMARC DKIM Checker with selector1 and selector2 to confirm both records resolve. If you’re unsure which value to enter, see how to find your DKIM selector. To read raw headers, use our email header analyzer.

How to Set Up DKIM in Office 365 with PowerShell

If you’d rather use PowerShell to enable DKIM signing of outbound messages using a custom domain, or to customize DKIM signing for the initial *.onmicrosoft.com domain, connect to Exchange Online PowerShell and run the following commands.

Tip: Before you can configure DKIM signing using the custom domain, you need to add the domain to Microsoft 365. To confirm that the custom domain is available for DKIM configuration, run Get-AcceptedDomain.

Your *.onmicrosoft.com domain is already signing outbound email from senders in that domain by default. Typically, unless you manually configured DKIM signing for the *.onmicrosoft.com domain in the Defender portal or in PowerShell, it doesn’t appear in the output of Get-DkimSigningConfig.

Step 1: Verify the Availability and DKIM Status of Your Domains

Connect to Exchange Online PowerShell:

Connect-ExchangeOnline

Then run the following command to verify the availability and DKIM status of all domains in the organization:

Get-DkimSigningConfig | Format-List Name,Enabled,Status,Selector1CNAME,Selector2CNAME

For the domain where you want to configure DKIM signing, the output of this command determines what you do next.

  • The domain is listed with Enabled: False and Status: NoDKIMKeys or CnameMissing. Go to Step 3 to copy the selector values.
  • The domain isn’t listed. Go to Step 2.

Step 2: Create the DKIM Signing Configuration (Only if the Domain Isn’t Listed)

Replace <Domain> with your domain and run:

New-DkimSigningConfig -DomainName <Domain> -Enabled $false [-BodyCanonicalization <Relaxed | Simple>] [-HeaderCanonicalization <Relaxed | Simple>] [-KeySize <1024 | 2048>]

  • BodyCanonicalization sets the sensitivity to changes in the message body.
    • Relaxed (default): Changes in whitespace and changes in empty lines at the end of the message body are tolerated.
    • Simple: Only changes in empty lines at the end of the message body are tolerated.
  • HeaderCanonicalization sets the sensitivity to changes in the message header.
    • Relaxed (default): Common modifications to the message header are tolerated, such as header field line rewrapping, changes in unnecessary whitespace or empty lines, and changes in case for header fields.
    • Simple: No changes to the header fields are tolerated.
  • KeySize sets the bit size of the public key in the DKIM record: 1024 (default) or 2048.

For example:

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

To create the configuration with a 2048-bit key from the start:

New-DkimSigningConfig -DomainName contoso.com -Enabled $false -KeySize 2048

Run the command from Step 1 again to confirm that the domain is now listed with Enabled: False and Status: CnameMissing. Then go to Step 3.

Step 3: Copy the Selector Values

Copy the Selector1CNAME and Selector2CNAME values for the domain from the output of the command in Step 1.

The CNAME records you need to create at your domain registrar look like this:

  • Hostname: selector1._domainkey, points to address or value: <Selector1CNAME value>
  • Hostname: selector2._domainkey, points to address or value: <Selector2CNAME value>

For example:

  • Hostname: selector1._domainkey, points to: selector1-contoso-com._domainkey.contoso.n-v1.dkim.mail.microsoft
  • Hostname: selector2._domainkey, points to: selector2-contoso-com._domainkey.contoso.n-v1.dkim.mail.microsoft

Step 4: Create the CNAME Records

Do one of the following:

  • Custom domain: At your domain registrar, create the two CNAME records using the information from Step 3 (see ‘Step 2: Publish the Two CNAME Records’ above for DNS host notes). It takes a few minutes, or possibly longer, for Microsoft 365 to detect the new CNAME records.
  • *.onmicrosoft.com domain: Go to Step 5.

Step 5: Enable DKIM Signing

After a while, return to Exchange Online PowerShell, replace <Domain> with the domain you configured, and run: 

Set-DkimSigningConfig -Identity <Domain> -Enabled $true [-BodyCanonicalization <Relaxed | Simple>] [-HeaderCanonicalization <Relaxed | Simple>]

The BodyCanonicalization and HeaderCanonicalization parameters work as described in Step 2.

For example:

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

Or, for the initial domain:

Set-DkimSigningConfig -Identity contoso.onmicrosoft.com -Enabled $true

  • Custom domain: If Microsoft 365 detects the CNAME records at your domain registrar, the command runs without error, and the domain is now used to DKIM sign outbound messages from that domain.
  • If the CNAME records aren’t detected, you get an error that contains the values to use in the CNAME records. Check for typos in the values at your domain registrar (easy to do with the dashes, periods, and underscores), wait a while longer, and then run the command again.
  • For a *.onmicrosoft.com domain that previously wasn’t listed, the command runs without error.

Step 6: Verify the Configuration

To verify that the domain is now configured to DKIM sign messages, run the command from Step 1 again:

Get-DkimSigningConfig | Format-List Name,Enabled,Status,Selector1CNAME,Selector2CNAME

The domain should show Enabled: True and Status: Valid.

How to Rotate DKIM Keys and Upgrade to 2048-Bit in Microsoft 365

Microsoft says to change DKIM keys periodically, the same way you change passwords, but it doesn’t prescribe an interval. Rotation is also how you move existing domains from 1024-bit to 2048-bit keys. You can rotate only when the domain’s toggle is Enabled, and its status is Valid or CnameMissing.

In the Defender portal: on the DKIM tab, select the domain’s row, then select Rotate DKIM keys at the bottom of the flyout. 

dkim office 365

Source: Official Microsoft guide

The status changes to “Rotating keys for this domain and signing DKIM signatures”, the Publish CNAMEs values go blank, and the button is grayed out.

dkim office 365

Source: Official Microsoft guide

In PowerShell:

Rotate-DkimSigningConfig -Identity contoso.com -KeySize 2048

Leave out -KeySize to keep the current key size.

What to expect:

  • The change isn’t immediate. The new key starts signing after four days (96 hours), and the old key is used until then. You can’t start another rotation while one is in progress.
  • Signing switches to 2048-bit after the first rotation (96 hours). A second rotation is needed for both selectors to be 2048-bit, so allow at least eight days for that.
  • To track progress, run this and watch KeyCreationTime, RotateOnDate, and the two selector properties:

Get-DkimSigningConfig | Format-List Name,Enabled,Status,Selector1CNAME,Selector1KeySize,Selector2CNAME,Selector2KeySize,KeyCreationTime,RotateOnDate,SelectorBeforeRotateOnDate,SelectorAfterRotateOnDate

  • Confirm which selector signs a message by checking the s= value in the DKIM-Signature header.

For background, read our guides on DKIM key rotation and DKIM key length (1024 vs 2048).

How to Check DKIM Status in Office 365

Method 1: Microsoft Defender portal. Open the DKIM tab at security.microsoft.com/authentication?viewid=DKIM. The domain should show the toggle Enabled and the status Valid (flyout: “Signing DKIM signatures for this domain”).

Method 2: DKIM checker. Enter your domain and selector1 or selector2 in the PowerDMARC DKIM Checker to confirm the records resolve.

dkim office 365

Method 3: Message headers. In a message received at an external mailbox, check that DKIM-Signature has d= set to your domain, and that Authentication-Results shows dkim=pass.

Office 365 DKIM Troubleshooting

ProblemCauseFix
Status shows CnameMissing or the toggle won’t enableMicrosoft 365 can’t detect the CNAME records yet, or they’re wrongRun dig CNAME selector1._domainkey.contoso.com +short (or nslookup -type=CNAME selector1._domainkey.contoso.com on Windows) for both selectors and compare with Defender. Detection can take minutes or longer, and DNS changes can take up to 48 hours.
Wrong target formatTarget built by hand: dots left in the domain, .onmicrosoft.com kept in the prefix, partition character missing, or the older format used on a domain that expects the newer oneCopy the values from Defender or Get-DkimSigningConfig.
Record exists but isn’t detectedHostname includes the domain (selector1._domainkey.contoso.com.contoso.com), or a TXT record was created instead of a CNAMEEnter only selector1._domainkey and use CNAME records.
Cloudflare proxy onProxied records return Cloudflare IPs instead of the CNAME targetSet the records to DNS only.
selector2 not working or rotation failsOnly selector1 was publishedPublish both records. See DKIM selector2 not working.
Intermittent dkim=temperrorTemporary DNS lookup failures; a very low TTL (60–300s) increases how often receivers querySet the TTL to 3600 or higher.
No DKIM-Signature in a test messageSender and recipient are in the same domain, or in domains controlled by the same organizationTest with an external mailbox.
DKIM passes, but DMARC failsThe d= domain doesn’t align with the From domain, for example when a third-party sender signs with its own domainEnable DKIM for the exact domain in the From address, including subdomains (an exact match is required if your DMARC record uses adkim=s), and configure third-party senders to sign with your domain. See why DKIM fails.
DKIM fails after forwardingAn intermediary modified the messageFor mail arriving in your tenant, Microsoft advises configuring the intermediary as a trusted ARC sealer.
Toggle returns to DisabledRare: records detected but keys can’t be generatedContact Microsoft Support with the Get-DkimSigningConfig output.

Hybrid and on-premises Exchange: Microsoft notes that Exchange 2016 and later are known to modify messages that flow through them, which can affect DKIM. See our guide to DKIM on on-prem Exchange.

Set Up DKIM for Office 365 the Right Way with PowerDMARC

Enabling DKIM is only the first step. You also need to know it keeps working. PowerDMARC’s DMARC reports show DKIM results for every source sending as your domain, including Microsoft 365, so you can see which messages pass DKIM and alignment. Alerts flag failing sources, which helps you catch a missing CNAME or a stalled rotation before it affects delivery. From the same reports, you can move toward DMARC enforcement with confidence. Learn more about DMARC for Office 365.

Frequently Asked Questions

Is DKIM enabled by default in Office 365?

Only for your initial onmicrosoft.com domain, which Microsoft signs automatically. Custom domains are not signed with your own domain until you publish two CNAME records and enable signing in Microsoft Defender or with Set-DkimSigningConfig. Each custom domain and sending subdomain needs its own setup.

Where do I find DKIM settings in Microsoft 365?

In the Microsoft Defender portal, go to Email & collaboration > Policies & rules > Threat policies > Email authentication settings, then open the DKIM tab. The direct link is security.microsoft.com/authentication?viewid=DKIM. In Exchange Online PowerShell, use Get-DkimSigningConfig to see each domain’s status and selectors.

What key size does Microsoft 365 use for DKIM?

Microsoft’s documentation lists 1024 bits as the default for New-DkimSigningConfig. You can choose 2048 with -KeySize 2048 or switch during key rotation. Run Get-DkimSigningConfig and check Selector1KeySize and Selector2KeySize to see what your domain uses. 2048-bit is the stronger choice.

How do I rotate DKIM keys in Office 365?

Select the domain on the DKIM tab and choose Rotate DKIM keys, or run Rotate-DkimSigningConfig. The new key signs after 96 hours, and you can’t start another rotation meanwhile. Microsoft doesn’t document disabling and re-enabling DKIM as a rotation method.

Why does my DKIM CNAME show as missing?

CnameMissing means Microsoft 365 can’t detect the expected records. Common causes are typos in the target, a domain suffix added to the hostname, a TXT record instead of a CNAME, a proxied Cloudflare record, or a DNS change that hasn’t propagated. Copy the values again from Defender and retry.

Do I need SPF and DMARC as well as DKIM?

Yes. Microsoft states that DKIM alone isn’t enough to prevent spoofing of your domain. SPF authorizes sending servers, DKIM verifies message integrity, and DMARC checks that SPF or DKIM passes and aligns with the From domain, tells receivers your preferred handling, and gives you reporting.

dkim office 365