Back to dashboard

Microsoft 365: SPF, DKIM and DMARC

What this guide is for

Microsoft 365 (Exchange Online) automatically signs email from the *.onmicrosoft.com domain, but not from your custom domain. For your messages to be signed with your domain, you publish two DKIM CNAME records and then turn on signing in the Microsoft Defender portal.

Expected records

Type Name (host) Value
TXT (SPF) your domain (@) v=spf1 include:spf.protection.outlook.com ~all (or the include added to your existing SPF record)
CNAME selector1._domainkey value provided by Microsoft (e.g. selector1-example-com._domainkey.<tenant>.n-v1.dkim.mail.microsoft)
CNAME selector2._domainkey value provided by Microsoft (same form, with selector2)
TXT (DMARC) _dmarc v=DMARC1; p=none; rua=mailto:[email protected]
MX your domain <domain-with-dashes>.mail.protection.outlook.com (or a value under mx.microsoft)
  • For Microsoft 365, the DKIM key is always published as a CNAME, never as TXT.
  • Create both CNAME records, even though only one selector is active at a time: the second one is used for key rotation.
  • Do not build the values by hand: depending on when the tenant was created, they point to dkim.mail.microsoft or to your onmicrosoft.com domain. Copy them from the portal.

Steps in the Microsoft Defender portal

The domain must first be added and verified in Microsoft 365.

  1. Open the Defender portal at https://security.microsoft.com/authentication, or go to Email & collaboration > Policies & rules > Threat policies > Email authentication settings.
  2. Open the DKIM tab and select your custom domain.
  3. If no keys exist yet, choose Create DKIM keys.
  4. In the details flyout, in the Publish CNAMEs section, copy both values.
  5. Create both CNAME records at your DNS host.
  6. Once the records are detected, return to the domain flyout and turn on Sign messages for this domain with DKIM signatures. The status becomes "Signing DKIM signatures for this domain". If the CNAME records are not visible yet, the status stays at CnameMissing.

Detection can take from a few minutes to 4 days depending on your DNS. In Exchange Online PowerShell, Get-DkimSigningConfig returns the Selector1CNAME and Selector2CNAME values, and Set-DkimSigningConfig -Identity example.com -Enabled $true turns signing on.

Check the setup

  1. In the DKIM tab, the domain should show signing as active.
  2. Send an email from a Microsoft 365 mailbox to an external address and check the headers for dkim=pass header.d=example.com.
  3. Run a new scan in this tool: the selector1 and selector2 selectors should be detected.

DMARC

Publish a single TXT record at _dmarc.<your domain>, starting with monitoring:

v=DMARC1; p=none; rua=mailto:[email protected]

Read the reports for a few weeks, check that all your legitimate mail passes, then move gradually to p=quarantine and p=reject.

Official documentation

Microsoft 365: setup guide - SEKOIA