Library

Guides Quick Fixes Scripts Find a Guide

Tools

Error Decoder Assessment Baselines Free Tools Service status What's Changed

More

AI Certifications For MSPs Recommended Gear Field Kit FAQ About Contact Get Assessment

Set Up DKIM and DMARC for Exchange Online Custom Domains

EntraReady Guides · Practical Microsoft 365 & Entra ID
Last reviewed:
Last verified against Microsoft Learn:

SPF, DKIM and DMARC together let receiving mail systems check that mail claiming to come from your domain really did. Microsoft 365 signs mail from your *.onmicrosoft.com domain automatically, but no DKIM signing happens for custom domains until you set it up (DKIM (opens in a new tab)). DMARC then tells receivers what to do when SPF and DKIM don't line up with the From address (DMARC (opens in a new tab)). DKIM alone isn't enough; Microsoft's guidance is to configure all three.

Use it when: you onboard a new tenant or domain, a customer is being spoofed, or a receiving provider starts rejecting or junking your mail.

Before you start

Step 1: SPF first

Each domain or subdomain that sends mail needs exactly one SPF TXT record; multiple records cause permerror. Most Microsoft 365 organizations need include:spf.protection.outlook.com. Microsoft recommends -all (hard fail) when you also deploy DKIM and DMARC, and the record must stay under 10 DNS lookups (SPF (opens in a new tab)). Cloud-only example:

v=spf1 include:spf.protection.outlook.com -all

Step 2: DKIM for each custom domain

  1. In the Defender portal go to Email & collaboration > Policies & rules > Threat policies > Email authentication settings > DKIM (or https://security.microsoft.com/authentication?viewid=DKIM). The domain should show Toggle: Disabled and Status: NoDKIMKeys (Enable DKIM (opens in a new tab)).
  2. Try to switch the toggle on. A Client error dialog appears (expected). Select OK, and the status becomes CnameMissing.
  3. Open the domain's details flyout and copy the two values under Publish CNAMEs.
  4. At your DNS host, create both CNAMEs. Hostnames are always selector1._domainkey and selector2._domainkey. Always copy the targets from the portal or PowerShell: domains added since May 2025 use a newer format (selector1-contoso-com._domainkey.contoso.n-v1.dkim.mail.microsoft, with a dynamic partition character), while older domains use selector1-contoso-com._domainkey.contoso.onmicrosoft.com. The two formats can't coexist for the same selector (Syntax for DKIM CNAME records (opens in a new tab)). Use a TTL of at least 3600 seconds (TTL set too low (opens in a new tab)).
  5. After Microsoft 365 detects the records (minutes, sometimes longer), go back to the flyout and turn on Sign messages for this domain with DKIM signatures. Success shows Status: Signing DKIM signatures for this domain, and Rotate DKIM keys becomes available.
  6. Repeat for every subdomain that sends mail; each needs its own DKIM configuration (Subdomain considerations (opens in a new tab)).

Step 3: DMARC, gradually

Record syntax: hostname _dmarc, value v=DMARC1; p=<none|quarantine|reject>; pct=<0-100>; rua=mailto:<address>; ruf=mailto:<address>. If you leave out pct, it defaults to 100 (Syntax for DMARC TXT records (opens in a new tab)). Microsoft's rollout (Set up DMARC for active custom domains (opens in a new tab)):

  1. Start with a low-volume domain or subdomain at p=none and read the aggregate (rua) reports to find every legitimate sender.
  2. Move to p=quarantine, optionally stepping pct through 10, 25, 50, 75 and 100.
  3. Move to p=reject.
  4. Repeat for the remaining subdomains and do the parent domain last. Subdomains inherit the parent's DMARC record unless they have their own.

Example starting record: v=DMARC1; p=none; pct=100; rua=mailto:rua@contoso.com

Parked domains (registered but never used for mail): publish v=DMARC1; p=reject; and no DKIM records. This includes the *.onmicrosoft.com domain if you don't send from it. Add its DMARC record in the Microsoft 365 admin center under Settings > Domains > [onmicrosoft domain] > DNS records > Add record (TXT, name _dmarc) (Parked domains (opens in a new tab), onmicrosoft.com DMARC (opens in a new tab)).

Report-first PowerShell

Read-only checks in Exchange Online PowerShell. Resolve-DnsName runs on Windows. These commands come from Learn's DKIM and DMARC troubleshooting sections (DMARC PowerShell commands (opens in a new tab), DKIM (opens in a new tab)).

Connect-ExchangeOnline
# DKIM status and the exact CNAME targets for every domain
Get-DkimSigningConfig | Format-List Name, Enabled, Status, Selector1CNAME, Selector2CNAME
# Key age and rotation details for one domain
Get-DkimSigningConfig -Identity contoso.com |
Format-List KeyCreationTime, RotateOnDate, SelectorBeforeRotateOnDate, SelectorAfterRotateOnDate
# What's published in DNS
Resolve-DnsName -Name "_dmarc.contoso.com" -Type TXT | Select-Object -ExpandProperty Strings
Resolve-DnsName -Name "contoso.com" -Type TXT | Where-Object { $_.Strings -like "v=spf1*" }
# How Microsoft 365 treats inbound mail that fails the sender's DMARC
Get-AntiPhishPolicy | Format-List Name, HonorDmarcPolicy, DmarcQuarantineAction, DmarcRejectAction

Leave changes (New-DkimSigningConfig, Set-DkimSigningConfig, Rotate-DkimSigningConfig) to a reviewed change window.

Gotchas

Check it worked

Roll back

Lower DMARC back to p=quarantine or p=none in DNS. DKIM signing for a custom domain can be turned off in the domain's flyout on the DKIM tab or with Set-DkimSigningConfig -Enabled $false (Disable DKIM signing (opens in a new tab)).

Related on EntraReady: Block legacy authentication, Guest access cleanup, Investigate risky users and sign-ins.

← All Guides

Is this still accurate?

Spotted something outdated or wrong on this page? Tell us in a sentence. The page address is sent with it.

Reports go to the EntraReady inbox. Please don’t include passwords or tenant secrets.