Introducing Accessibility Controls: the tools to build accessible, WCAG compliant signatures, built right into Exclaimer.Learn more

How to set up DKIM in Microsoft 365 (without breaking your email signatures)

Published

Updated

Image Placeholder

TL;DR

  • DKIM (DomainKeys Identified Mail) adds a cryptographic signature to your outbound email, so receiving servers can confirm the message came from your domain and wasn't altered in transit.

  • In Microsoft 365 (still commonly called Office 365), you enable DKIM per domain from the Microsoft Defender portal or with Exchange Online PowerShell, then publish two CNAME records in your DNS.

  • Use a 2048-bit key and rotate it at least once a year. The PowerShell default is a weaker 1024-bit key, so specify the stronger size yourself.

  • Adding an email signature after Microsoft 365 has already signed a message breaks DKIM. Sign after the signature is inserted, not before, and confirm it with dkim=pass in the Authentication-Results header.

If you're setting up email authentication for your domain, DKIM is the piece most likely to cause friction later, especially if you also manage email signatures across the business. Fewer than one-third of organizations have implemented DMARC, DKIM, or SPF, according to Exclaimer's State of Business Email 2025, so configuring it at all puts you ahead of most senders.

This guide walks through what DKIM is, how to enable it in Microsoft 365 using the Defender portal or PowerShell, how to rotate your keys, and how to test that it's working. It also answers the question most IT teams have when adding a signature tool: whether inserting an email signature breaks DKIM, and how to configure Microsoft 365 so it doesn't.

"Email has something most channels don't: authentication standards. DMARC, DKIM, SPF. Imperfect, but they exist. ... But that trust depends on organizations actually implementing these standards properly. The gap between companies with enforced DMARC and those without will widen. The latter become prime targets for impersonation."

Karl Bagci
Karl BagciDirector of IT & Information Security

What is DKIM and how does it work?

DKIM, or DomainKeys Identified Mail, is an email authentication method that attaches a digital signature to every message you send. It lets the receiving server confirm the message came from your domain and wasn't altered in transit. It works with a pair of cryptographic keys: a private key that stays with your mail server, and a public key you publish in DNS. Your server signs outbound messages with the private key, and receiving servers use the public key to verify the signature.

DKIM doesn't encrypt anything or hide the message content. It signs the message so the recipient can trust two things: your domain authorized it, and the parts covered by the signature haven't changed since signing. That second guarantee is exactly why email signatures and DKIM can collide, which we get into below.

The DKIM signing and verification process

When your mail server sends a message, it hashes selected headers and the message body, signs that hash with your private key, and adds the result as a DKIM-Signature header. The receiving server looks up your public key in DNS, uses it to verify the signature, and recomputes the hash from the message it actually received. If the two hashes match, DKIM passes. Matching hashes mean DKIM passes. If anything covered by the signature changed after signing, the hashes won't match and DKIM fails.

DKIM validates the message exactly as it existed the moment of signing. Change the signed content afterward, and validation breaks.

DKIM vs. SPF vs. DMARC

DKIM is one of three authentication standards that work together, each doing a different job.

Standard

What it does

Where it's configured

SPF

Tells receiving servers which servers are allowed to send mail for your domain

Your SPF record

DKIM

Proves the message content is authentic and unaltered since signing

Microsoft Defender portal or PowerShell

DMARC

Ties SPF and DKIM together: tells receivers what to do when a message fails either check, and reports back on what's happening

A DMARC policy record in your domain's DNS

How to enable DKIM in Microsoft 365

You can turn on DKIM signing for a custom domain two ways: through the Microsoft Defender portal, or with Exchange Online PowerShell. Both do the same job. They generate a key pair, give you two CNAME records to publish, and switch signing on once those records resolve. Your initial onmicrosoft.com domain is already DKIM-signed by default, so these steps apply to the custom domains you actually send from.

Before you start, add the domain to Microsoft 365 if you haven't already, and confirm you can edit records at your DNS host, where your MX record and other mail settings already live.

Enable DKIM in the Microsoft Defender portal

  1. Go to the Defender portal at security.microsoft.com and open Email & collaboration > Policies & rules > Threat policies > Email authentication settings. You can jump straight there with security.microsoft.com/authentication.

  2. Select the DKIM tab, then click the domain you want to configure.

  3. In the flyout, find the two CNAME records under Publish CNAMEs and copy both exactly.

  4. Create those two CNAME records at your DNS host, then wait for them to resolve.

  5. Return to the flyout and switch Sign messages for this domain with DKIM signatures to Enabled. Status changes to Valid once Microsoft detects the records.

Enable DKIM with PowerShell

If you'd rather script it, connect to Exchange Online PowerShell and check the current state first:

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

If your custom domain isn't listed, create a signing configuration in a disabled state. This generates the keys and selector values without signing anything yet:

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

Copy the Selector1CNAME and Selector2CNAME values from the output, publish them as CNAME records at your DNS host, and once they resolve, enable signing:

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

Run Get-DkimSigningConfig again to confirm Enabled is True and Status is Valid. New-DkimSigningConfig defaults to a 1024-bit key, so add -KeySize 2048 if you want the stronger size from the start.

Publish the DKIM CNAME records in DNS

Microsoft 365 doesn't ask you to publish the public key directly. You publish two CNAME records that point to Microsoft's DKIM infrastructure, and Microsoft manages the underlying keys for you. That's why CNAMEs are used here rather than the raw TXT record some other platforms use. A TXT key by hand leaves the status stuck on CnameMissing.

For a new custom domain, the records follow this format, introduced in May 2025:

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

Domains configured before that change use an older format ending in your onmicrosoft.com domain. Either way, don't build these values by hand because a single wrong dash or dot leaves signing broken. Publish both records even though only one selector is active at a time, since the inactive selector is what lets keys rotate later without downtime. Set the TTL to at least 3600 seconds to avoid intermittent lookup failures.

Does adding an email signature break DKIM?

It can, but with the right setup it won't. Inserting an email signature changes the message, and DKIM exists specifically to detect that kind of change. This is why signature tools and DKIM need to be configured to work together.

Most server-side signature tools add the email signature by routing outbound mail through a transport rule that inserts HTML into the message body. If that HTML is added after Microsoft 365 has already applied the DKIM signature, the body no longer matches what was signed, and DKIM fails at the receiving end. That's the failure mode IT teams are right to worry about before they roll a signature tool out company-wide.

The fix is the order of operations. Exclaimer's cloud solution strips the DKIM signature on receipt, inserts the email signature, and returns the message to Microsoft 365, which re-applies DKIM after the signature is in place and before delivery. Because the final signing happens after the content is added, the signature the recipient verifies matches the message they receive, and DKIM passes.

Getting the order wrong is easy to miss, because the email still looks correct to the sender while quietly failing authentication at the other end. You don't have to take a vendor's word for where signing happens: send a real test message with the signature already applied, and check for dkim=pass in the Authentication-Results header, the same way you'd validate DKIM on its own (see the testing section below). A Valid status in the Defender portal only confirms your DKIM configuration exists; it says nothing about whether a signature inserted later broke it.

How to rotate your DKIM keys in Microsoft 365

DKIM keys are credentials, and like any signing credential, they should be rotated on a schedule: at least once a year. Microsoft 365 doesn't rotate custom domain keys for you, so this is a task you own.

The two CNAME records you published earlier are what keep rotation from disrupting mail flow. One selector signs your mail while the other sits on standby. When you rotate, Microsoft 365 activates the standby selector with a fresh key and retires the old one, so signing never stops.

To rotate in the Defender portal, open the DKIM tab, select the domain, and choose Rotate DKIM keys at the bottom of the flyout.

To rotate with PowerShell:

Rotate-DkimSigningConfig -Identity contoso.com

To move up to a 2048-bit key at the same time, add the KeySize parameter:

Rotate-DkimSigningConfig -Identity contoso.com -KeySize 2048

Rotation isn't instant. The new key takes four days (96 hours) to start signing, and the current key keeps signing until then. You can't start a second rotation while one is in progress. There's one gotcha when raising the bit depth: the 2048-bit size applies only to the next active selector on this rotation, so the other selector updates to 2048 on the following rotation.

How to test and validate your DKIM record

A Valid status in the portal confirms your configuration, not that receivers accept your signature. Check both: the configuration in Microsoft 365, then a real message.

Start in PowerShell. Get-DkimSigningConfig should return Enabled as True and Status as Valid for your domain:

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

Then test an actual email. Send a message from the domain to an external mailbox you control, open it, and view the original source or headers. Look for dkim=pass in the Authentication-Results header. You'll also see a DKIM-Signature header whose d= value matches your domain and whose s= value shows which selector signed the message, for example s=selector1-contoso-com.

A DKIM validation tool does the same check without reading headers by hand. Send a message to the address the tool gives you, or enter your domain and selector, and it reports whether the signature verifies against your published key. Either way, a passing result means the receiving side can validate your signature against DNS.

Common DKIM problems and how to fix them

Most DKIM problems in Microsoft 365 trace back to DNS or timing rather than DKIM itself. The failures below are the ones you're most likely to hit, with the fix for each.

Problem

What's happening

How to fix

Status stuck on CnameMissing right after publishing

DNS changes haven't propagated yet

Wait for the records to resolve, which can take minutes to hours, then re-check. Confirm both CNAMEs resolve before troubleshooting further.

Status stays CnameMissing after propagation

A mistyped selector target: dots kept instead of dashes, wrong onmicrosoft.com prefix, or a missing dynamic partition character

Copy the exact values from the Defender portal or Get-DkimSigningConfig. Don't build the target by hand.

A TXT record was published instead of a CNAME

Microsoft 365 needs CNAMEs that delegate key management to Microsoft, so a raw TXT public key isn't supported

Delete the TXT record and publish the two CNAME records.

Intermittent dkim=temperror or dkim=fail

The TTL on the CNAME records is set too low, causing DNS lookups to time out

Raise the TTL on both records to at least 3600 seconds.

dkim=fail with a body hash mismatch

The message body changed after DKIM signing, often a signature or disclaimer added later in the mail flow

Route mail so signing happens after the content is inserted.

Rotation appears to do nothing, or won't start again

Rotation takes 96 hours, and a second rotation is blocked while one is in progress

Wait for the current rotation to finish before starting another.

If a message still fails once you've ruled out these causes, read the full Authentication-Results header. It shows whether the failure is DKIM, SPF, or DMARC, so you can isolate the problem instead of guessing.

Done right, you don't have to choose between authenticated mail and consistent, branded email signatures.

Email signatures that keep DKIM intact

See how Exclaimer's cloud solution adds email signatures in the right order, so authentication keeps passing.

Hero Image

Frequently asked questions about DKIM in Microsoft 365

Is DKIM required for Microsoft 365?

DKIM isn't strictly mandatory, but Google and Yahoo have required bulk senders to authenticate with both SPF and DKIM since February 2024. Microsoft 365 already signs mail from your onmicrosoft.com domain by default, though you need DKIM on your custom domain for it to count toward DMARC alignment. Skip it, and more of your mail ends up in spam.

Yes. Office 365 was rebranded to Microsoft 365 in 2020, and DKIM setup, the Defender portal, and the PowerShell cmdlets are identical whichever name you're used to. Search results and documentation still use both names interchangeably for this reason.

Yes. The Microsoft Defender portal handles the same DKIM enablement PowerShell does, without any scripting: open Email & collaboration > Policies & rules > Threat policies > Email authentication settings, select the DKIM tab, and enable signing for your domain.

At least once a year, the same way you'd cycle any signing credential. Microsoft 365 doesn't rotate custom domain keys automatically, so you trigger it in the Defender portal or with Rotate-DkimSigningConfig. Each rotation takes 96 hours to take effect, and signing continues on the current key until it does.

Use a 2048-bit key. It's the current recommendation for stronger protection, though the New-DkimSigningConfig cmdlet still defaults to 1024-bit, so specify -KeySize 2048 when you create or rotate the key.

They're three separate checks that work together. SPF lists which servers may send for your domain, DKIM proves the message wasn't altered after signing, and DMARC sets the policy for what happens when SPF or DKIM fails and reports on the results. All three belong in place for reliable authentication.

Not if signing happens in the right order. A signature only breaks DKIM when it's inserted after Microsoft 365 has signed the message, which changes the body so it no longer matches the signature. Route mail so the signature is added first and Microsoft 365 signs afterward; Exclaimer's cloud solution is built to work this way.

Usually because the CNAME records haven't propagated yet, or the target value is mistyped. Give DNS time to resolve, then confirm both records exactly match the values from the Defender portal or Get-DkimSigningConfig. If you published a TXT record instead of a CNAME, replace it, since Microsoft 365 only supports CNAME delegation.