Microsoft 365 DKIM Setup: CNAME Records and Fixes

Set up Microsoft 365 DKIM for a custom domain: publish the selector1 and selector2 CNAME records, verify them, and fix the common errors.

Published on

•

Updated

•

Microsoft 365 DKIM Setup: CNAME Records and Fixes
Do not index
Do not index
selector1._domainkey and selector2._domainkey must both be published as CNAME records pointing to the target values shown in Microsoft 365; custom-domain DKIM stays inactive until both resolve publicly and signing is enabled. A working mailbox doesn't prove that messages sent from the custom domain carry its DKIM signature.
Table of Contents

Microsoft 365 DKIM CNAME Records to Publish

Microsoft 365 DKIM connects an organization's domain to Microsoft-managed signing keys. DomainKeys Identified Mail (DKIM) adds a cryptographic signature that receiving servers can validate against a public key published through DNS.
The tenant's initial domain and its custom domains behave differently. Microsoft's DKIM configuration documentation states that outbound messages from the initial *.onmicrosoft.com domain are signed automatically, while custom domains require configuration and two published CNAME records.
The two selectors carry separate jobs. selector1 points resolvers to the key signing mail today; selector2 holds the next key so a future rotation needs no DNS change. Both go up at once. The targets above assume a tenant named example with domain example.com, and the issued values encode the actual tenant and domain names, so the Defender configuration and official documentation take precedence over any reconstructed hostname.
The CNAME type matters because it hands public-key discovery to Microsoft's endpoint. Copying the current public key into a TXT record at the selector hostname freezes that delegation: the static record keeps answering with one key even after Microsoft moves to the next, and signatures start failing against a stale key.

What a correct lookup looks like

Query each fully qualified hostname, selector1._domainkey.yourdomain.com and selector2._domainkey.yourdomain.com, with the mailX CNAME lookup. For the example tenant above, a good answer returns selector1-example-com._domainkey.example.onmicrosoft.com verbatim. A mismatched tenant returns the same shape built from its own names, and a DNS host that appends the parent domain a second time produces a doubled suffix like ...onmicrosoft.com.yourdomain.com, which will never resolve to Microsoft's key. CNAME troubleshooting with mailX covers how aliases and appended suffixes distort these answers.
For RevOps teams coordinating sending platforms, MarTech Do's email marketing guidance for RevOps teams provides broader operational context. DNS publication still needs a named technical owner: copy both issued targets exactly before opening the DNS host.

How to Enable DKIM for a Custom Domain

A Microsoft 365 mailbox can send and receive mail while DKIM signing for its custom domain remains disabled. Confirm the domain is verified in Microsoft 365 and identify the authoritative DNS host before changing the DKIM settings.
notion image

Which settings need changing in Defender?

  1. In the Microsoft 365 admin center, finish adding and verifying the custom domain.
  1. Open Microsoft Defender and go to Email & collaboration → Policies & rules → Threat policies → DKIM, then select the custom domain. Menu placement can change, so confirm the current path in Microsoft's documentation.
  1. Copy the CNAME target shown for each selector. Keep each selector paired with its own target.
  1. Publish both records in the domain's authoritative DNS zone. Select CNAME, not TXT, and turn off any proxy feature for these records.
  1. In Defender, select the domain and check its configuration status. Enable DKIM signing once the status is Valid.
For example, if Defender lists selector1._domainkey.example.com and selector2._domainkey.example.com, publish each hostname with its own displayed target. If the status is not Valid, compare the DNS entries with the values shown for that domain before changing records. Don't repeatedly replace correct records while cached answers are still updating.

What is the PowerShell equivalent?

In an authenticated Exchange Online PowerShell session, retrieve the configuration before making changes.
Compare the returned targets with Defender before publishing anything. PowerShell makes configuration repeatable across domains, but DNS validation still applies.
Protect the accounts that can change these settings with appropriate administrative controls. For related guidance, see Microsoft 365 MFA and security alerts.
In Defender, proceed when the custom domain's configuration status is Valid.

How to Check the Published CNAME Records

The Defender toggle can read Enabled while public resolvers still return nothing for the selector hostnames. Internal resolvers can also answer differently from public resolvers, and a recent DNS change can remain cached after the DNS control panel shows the new value.
Microsoft's DNS setup guidance specifies CNAME records with copied Microsoft 365 values and gives a sample TTL of 3600 seconds, or one hour. That sample is a cache setting, not a promise that signing will activate within the same period.

What should each lookup return?

  1. Enter selector1._domainkey.example.com into the mailX CNAME lookup, substituting the actual custom domain.
  1. Repeat the lookup for selector2._domainkey.example.com. Each selector is its own job: one CNAME resolving proves nothing about the other.
  1. Compare each returned alias with its corresponding target in Defender or PowerShell.
  1. Follow the CNAME chain and confirm that public-key retrieval succeeds at Microsoft's endpoint.
Empty answers: The record may be absent, published in an inactive DNS zone, cached as nonexistent, or entered under the wrong hostname. Check the authoritative DNS provider before assuming that more waiting will fix it.
Different answers: A target mismatch indicates a copying or tenant-selection error. The clearest case is a proxied record. Where the expected answer is a _domainkey hostname Microsoft issued, often ending in onmicrosoft.com, a Cloudflare record with the proxy enabled answers with a Cloudflare edge address instead. Disable proxying on that record so public DNS exposes the Microsoft target, then look the hostname up again.

How to verify it

A matching alias confirms only the first hop. verify your DKIM record with the custom domain and each selector separately, since selector1 and selector2 publish independent keys. A good result retrieves the published public key and reports its status. A CNAME that resolves but leads to no retrievable key is still a fail: work the target chain and the tenant's DKIM configuration rather than counting alias existence as a pass.

How to Confirm DKIM Signing in a Delivered Message

Send a fresh message from a Microsoft 365 mailbox on the custom domain to an external mailbox under the administrator's control. DNS proves that a receiver can find a key; the delivered message proves whether the sending path used it.
  1. Open the external mailbox's full message source or original headers.
  1. Locate DKIM-Signature and inspect its signing domain, d=.
  1. Read the selector, s=, and compare it with the published selector.
  1. Locate the receiving server's Authentication-Results header and check its DKIM verdict.
A passing signature from the tenant's default domain isn't the intended custom-domain result. Check the exact d= value rather than stopping at the word pass.
A published selector with a failing signature needs a different investigation from a missing selector. Message changes in transit can invalidate a signature even when DNS is correct; the receiver's diagnostic details help distinguish that from a key or selector mismatch.

How to verify it

Run the mailX DKIM checker with the domain and selector1, then repeat with selector2. The checker confirms key discovery, while the external receiver confirms message-level signature validation. Neither result replaces the other.
notion image

Common Mistakes and Error Messages Explained

CNAME record does not exist for this config means Defender couldn't detect the required selector CNAME during validation. The useful question isn't whether a record appears in the DNS dashboard, but whether public DNS returns the exact hostname and target Microsoft expects.

Is Intune CNAME validation the same problem?

Intune's CNAME validation failed is a related DNS troubleshooting query, not a Microsoft 365 DKIM status. Intune uses its own service-specific hostnames and targets; substituting DKIM selector records won't resolve device-management discovery or enrollment validation.
The same diagnostic method applies: compare the issued name and target, confirm public visibility, and check the relevant Microsoft Intune documentation. Also confirm that the custom domain is verified before attempting service activation.

Which unrelated errors should stay separate?

Duplicate SPF records and exceeding SPF's 10-DNS-lookup limit are SPF problems, not DKIM CNAME failures. The mailX SPF checker detects those conditions; changing DKIM records won't repair them.
Likewise, a wrong SMTP port/encryption pair or a missing app password, where that authentication method is supported and required, belongs to connection troubleshooting. The mailX SMTP test can investigate supported connection and login checks for an authorized mailbox, but those failures don't establish whether DKIM is configured.

How to verify it

Correct the host, correct the target, confirm publication with the mailX CNAME lookup, and retry validation. Once Defender accepts the configuration, check the public key and a newly delivered signature rather than repeatedly testing an old message.

Keeping selector2 Ready for Key Rotation

Mail can pass DKIM today while the domain remains unprepared for a key change. A missing standby selector may stay unnoticed because the active selector still supplies a valid key.
Microsoft's DKIM documentation describes two key pairs, with one used for signing and the other retained for rotation; both selector CNAMEs are required. The practical distinction is current validation versus rotation readiness.

Which states should an administrator record?

  • Active selector valid: The selector named in a fresh message resolves, the receiver validates its signature, and Defender reports a Valid configuration.
  • Standby selector present: The other selector resolves to the target issued for the same domain and exposes its public key.
  • Rotation-ready: Both records remain intact after DNS migrations and changes, rather than only appearing in an old setup checklist.
Selector names aren't permanent job assignments. selector1 may be active during an initial check, but administrators should read the message's s= value instead of assuming that selector2 always remains on standby.
Administrators can understand DKIM selector lookups with mailX when documenting which record a signature uses. Record the check date and repeat the inspection after DNS changes, before planned rotation, and after any rotation that occurs.

How to verify it

Use the mailX CNAME lookup and DKIM checker for each selector independently. A missing standby answer means the domain isn't rotation-ready, even when current messages pass. This inspection doesn't require initiating a key rotation.

Confirm Every Sender Before You Call DKIM Done

A sales team connects its CRM to the custom domain and starts sending quotes through the vendor's own servers. Microsoft 365 signs only the tenant's outbound mail. That CRM traffic never reaches Microsoft's signing configuration, and the same applies to marketing platforms, helpdesks, and transactional systems: each runs its own sending path with its own DKIM setup.
Microsoft's email authentication overview distinguishes SPF authorization, DKIM signatures, and DMARC alignment and policy. A signature Microsoft applies covers only the messages Microsoft transmits.
notion image

What belongs in the sender inventory?

  1. List every platform sending with the custom domain.
  1. Send a representative message from each platform to an external mailbox.
  1. Record its d= signing domain, s= selector, and receiver result.
  1. Confirm alignment between the signing domain and visible From domain for DKIM-based DMARC authentication. DMARC can also pass through aligned SPF.
  1. Repeat after adding or changing a sending platform.
Every stream needs its own evidence. External platforms sign under their own selector names, so a passing mailbox-to-mailbox message leaves each third-party stream untested.
For teams applying IronPeak Marketing's sales email examples, the inventory should include the platform transmitting the messages, not merely the mailbox shown in the From field.

How to verify it

For platforms outside Microsoft 365, query the selector named in each vendor's setup documentation rather than Microsoft's selector names. The mailX dkim-check endpoint accepts a selector and, when none is supplied, tries common selectors and returns the ones it finds. A returned key confirms the selector publishes a public key; the representative message from the inventory confirms the platform signs with it. A full domain scan then rechecks SPF, DKIM, DMARC, BIMI, MX, and blacklist status for the entered domain in one pass.

Frequently Asked Questions About Microsoft 365 DKIM

Does a Microsoft 365 DKIM signature survive forwarding?

Often yes for simple forwarding: the DKIM-Signature header travels with the message and can still validate. When a forwarder, gateway, or list rewrites the body or headers enough to break the hash, that original signature can fail even though the visible From domain stays the same.

Does enabling DKIM change inbound mail or MX records?

No. DKIM signs outbound mail after the domain validates; it does not reroute inbound delivery or replace MX. Publish the CNAMEs, enable the domain, then confirm by reading the delivered signature rather than watching inbound behavior.

Can several custom domains in one tenant share one DKIM setup?

No. The CNAME targets are issued for a specific tenant and domain, so each accepted domain that sends branded mail needs its own records published and enabled. A pass on one domain does not transfer to another domain in the same tenant.

If DKIM passes, is DMARC finished?

A DKIM pass is evidence for that sending path. DMARC still depends on alignment with the visible From domain, either through that DKIM identity or through aligned SPF, so check the receiver verdict before treating the domain as covered.

Should old DKIM records be removed once Microsoft 365 signs?

Keep the Microsoft selector CNAMEs while the custom domain sends through Microsoft 365. Remove only records tied to a retired platform after identifying which stream used them; deleting an active alias can turn a healthy stream unsigned.
mailX offers free, no-signup live DNS and email authentication checks with plain-English explanations and fixes. Visit mailX to check the Microsoft 365 selector records, confirm public-key availability, and identify what needs correcting before declaring custom-domain DKIM complete.

Most senders lose 30–70% of their emails to spam without knowing it.

Get a free expert audit of your domain, email authentication, and infrastructure. Identify hidden issues and fix them fast.

Book Your Free Deliverability Audit