Skip to content
Exchange & EmailGuide

SPF, DKIM, and DMARC for Microsoft 365, Set Up Correctly

The three DNS records that keep your mail out of spam folders and stop spoofing. What each one does, how to publish it for Exchange Online, and how to move DMARC to enforcement safely.

If your mail keeps landing in junk, or someone is spoofing your CEO's address, the fix is almost always the same three DNS records. Microsoft, Google, and Yahoo now expect SPF, DKIM, and DMARC from anyone sending real volume, and a missing or broken record is one of the most common findings in any tenant I review.

What each record does

RecordAnswers the questionLives at
SPFWhich servers are allowed to send mail for this domain?TXT record on the domain root
DKIMWas this message really signed by the domain, and was it changed in transit?Two CNAME records pointing to Microsoft
DMARCWhat should receivers do when SPF and DKIM fail, and who gets the reports?TXT record at _dmarc

SPF and DKIM prove a message is legitimate. DMARC ties them to the address the recipient actually sees, and tells the world what to do with fakes.

SPF

For a domain that sends only through Microsoft 365:

dns
yourcompany.com.  TXT  "v=spf1 include:spf.protection.outlook.com -all"

Rules that trip people up:

  • One SPF record per domain. Two v=spf1 records means SPF fails everywhere. Merge them.
  • Ten DNS lookup limit. Every include: counts. Stacking marketing tools, CRMs, and help desks can push you past ten, and then SPF fails.
  • Add every legitimate sender: newsletter platforms, invoicing systems, and your website's contact form. Check before you tighten anything.
  • -all vs ~all: -all (fail) is the goal once DMARC is doing its job. ~all (softfail) is fine while you're discovering senders.

DKIM

Exchange Online can sign outbound mail with your own domain, but only after you publish two CNAME records and turn signing on.

  1. In the Microsoft Defender portal, go to Email & collaboration -> Policies & rules -> Threat policies -> Email authentication settings -> DKIM.
  2. Select your domain. It shows the two CNAME records (selector1._domainkey and selector2._domainkey) with the exact values for your tenant.
  3. Publish both CNAMEs at your DNS host, wait for them to resolve, then enable signing.

You can check the configuration from Exchange Online PowerShell:

powershell
Connect-ExchangeOnline
Get-DkimSigningConfig | Format-Table Domain, Enabled, Status, Selector1CNAME, Selector2CNAME

DMARC

Start in monitoring mode, read the reports, then tighten:

dns
_dmarc.yourcompany.com.  TXT  "v=DMARC1; p=none; rua=mailto:dmarc@yourcompany.com"

The rollout I use:

  1. p=none with reporting on. Collect a few weeks of aggregate reports and find every legitimate sender that fails.
  2. Fix those senders. Add them to SPF, or better, set up DKIM signing on the platform itself.
  3. p=quarantine, optionally starting with pct= below 100 to phase it in.
  4. p=reject once reports show only spoofing is failing.

Checking your work

  • Send a message to an outside mailbox, open the full headers, and paste them into Microsoft's Message Header Analyzer. Look for spf=pass, dkim=pass, and dmarc=pass.
  • Use MxToolbox to check each record for syntax errors and SPF lookup count.
  • In the Defender portal, check that DKIM shows as enabled and valid.

Don't forget parked domains

Domains you own but don't send mail from are easy targets for spoofing. Lock them down completely:

dns
parkeddomain.com.         TXT  "v=spf1 -all"
_dmarc.parkeddomain.com.  TXT  "v=DMARC1; p=reject"
// Newsletter

New runbooks, straight to your inbox.

One email when something worth reading ships. No spam, unsubscribe anytime.