ZoneProbe

SPF, DKIM and DMARC for Microsoft 365

Microsoft 365 handles most of the hard work, but it doesn't turn on DKIM for your own domain by default, and that's the gap that makes DMARC fail. Here's the complete setup for a custom domain, in the order that avoids surprises.

By ZoneProbeUpdated 7 min read

What you'll set up

For a domain like example.com that sends and receives email through Microsoft 365 (Exchange Online), you need four kinds of DNS record. Microsoft's admin center shows most of them when you add the domain, but it's worth understanding each one, because the DKIM step happens somewhere else entirely.

RecordNameWhat it does
MX@Delivers incoming mail to Exchange Online
TXT (SPF)@Authorizes Microsoft's servers to send for your domain
2 × CNAME (DKIM)selector1._domainkey, selector2._domainkeyPoints to the public keys Microsoft uses to sign your mail
TXT (DMARC)_dmarcTells receivers what to do with mail that fails, and where to send reports

Throughout this guide, replace example.com with your domain. You'll need a Microsoft 365 admin account (Global Administrator, or Exchange and Security admin roles) and access to wherever your domain's DNS is hosted.

Step 1: confirm mail is flowing (MX)

If you already receive email in Microsoft 365, this is done. Otherwise the MX record comes from Microsoft 365 admin center › Settings › Domains › your domain › DNS records. It looks like one of these:

example.com.  MX  0  example-com.mail.protection.outlook.com.
example.com.  MX  0  example-com.o-v1.mx.microsoft.

The first format is the long-standing one. The second, ending in mx.microsoft, is used by domains that have Microsoft's inbound DNSSEC and DANE protection turned on. Use the value your admin center shows; it's specific to your domain, so don't copy one from another tenant. Remove any MX records left over from a previous mail provider, then check with the MX lookup.

Step 2: SPF

If Microsoft 365 is the only thing that sends email as your domain, your SPF record is a single line:

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

If you already have an SPF record, add the include to it rather than creating a second record. A domain with two SPF records fails SPF entirely. For example, with an on-premises server and a newsletter service:

v=spf1 ip4:203.0.113.25 include:spf.protection.outlook.com include:servers.newsletter.example -all
  • -all or ~all? Microsoft's own examples use -all. Once DMARC is in place, receivers follow your DMARC policy either way, so the choice matters less than people think. ~all is a little more forgiving while you're still discovering senders.
  • Watch the lookup count. Microsoft's include uses a couple of the 10 DNS lookups SPF allows. If you add many other services you can hit the limit; see fixing too many DNS lookups.

Check the result with the SPF checker.

Step 3: DKIM, the step most people miss

Microsoft 365 automatically DKIM-signs mail from your initial domain, the one ending in .onmicrosoft.com. It does not sign mail from your custom domain until you set it up. Depending on the age of your tenant, mail from example.com either carries no DKIM signature at all, or only one for the onmicrosoft.com domain:

DKIM-Signature: v=1; a=rsa-sha256; d=examplecorp.onmicrosoft.com; s=selector1-examplecorp-onmicrosoft-com; …

Either way, nothing is signed as example.com, so DKIM doesn't count for DMARC. Your mail then passes DMARC only through SPF, which breaks as soon as a message is forwarded. Turning on DKIM for your domain fixes this.

Get your CNAME records

  1. Go to the Microsoft Defender portal (security.microsoft.com) › Email & collaboration › Policies & rules › Threat policies › Email authentication settings, and open the DKIM tab.
  2. Select your domain. The details pane shows the status and two CNAME records to publish. If it says no keys exist yet, choose Create DKIM keys first.
  3. Copy both records exactly. Current ones look like this:
selector1._domainkey  CNAME  selector1-example-com._domainkey.examplecorp.n-v1.dkim.mail.microsoft
selector2._domainkey  CNAME  selector2-example-com._domainkey.examplecorp.n-v1.dkim.mail.microsoft

The part before -v1 varies between tenants, and older tenants use targets ending in onmicrosoft.com, so always copy the values from the portal rather than building them by hand.

Publish them and enable signing

  1. Add both CNAME records at your DNS host. If you use Cloudflare, set them to DNS only (grey cloud), not proxied.
  2. Wait for them to appear. Check with the DKIM checker using the selector selector1; it should show the key with "Delegated via CNAME".
  3. Back in the Defender portal, switch Sign messages for this domain with DKIM signatures to Enabled. If you get an error saying the CNAME records don't exist, DNS hasn't caught up yet; try again later.

Prefer PowerShell? In Exchange Online PowerShell:

Get-DkimSigningConfig -Identity example.com | Format-List Selector1CNAME, Selector2CNAME, Enabled
Set-DkimSigningConfig -Identity example.com -Enabled $true

If the first command finds nothing for your domain, create the configuration with New-DkimSigningConfig -DomainName example.com -Enabled $false, publish the CNAMEs it reports, then enable it.

Why two selectors?

Microsoft signs with one key while the other is ready for rotation. When you rotate keys (in the portal, or with Rotate-DkimSigningConfig), Microsoft switches to the other selector about four days later. Because both are CNAMEs pointing at Microsoft, the new key is already published and nothing changes in your DNS.

Check that it worked

Send a message from Outlook to an outside mailbox, such as a personal Gmail account, and paste its headers into the header analyzer. Don't test by sending to a colleague: Microsoft skips DKIM signing for mail between addresses in the same organization. You want to see DKIM: pass signed by example.com, and aligned with the From domain.

Step 4: DMARC

With SPF and DKIM in place, publish DMARC in monitoring mode at your DNS host:

_dmarc.example.com.  TXT  "v=DMARC1; p=none; rua=mailto:[email protected]"

The DMARC generator builds this for you. Then follow the rollout in How to set up DMARC: read the reports for a few weeks, fix any other service that sends as you, and move to p=quarantine and p=reject.

Microsoft 365 doesn't host the DMARC record for a custom domain; it lives with the rest of your domain's DNS. The aggregate reports will include Microsoft's own report about mail that Outlook.com and Exchange Online received from you.

Other things that send as your domain

Microsoft 365 is rarely the only sender. These are the common ones in Microsoft-based organizations:

Scanners, printers and apps using "direct send"

Devices often send straight to your Microsoft 365 MX endpoint without signing in, called direct send. That mail arrives from your office's public IP address, so add that address to SPF (ip4:). Better still, use authenticated submission (SMTP AUTH on port 587) or an SMTP relay connector, so it goes through Microsoft 365 properly and gets DKIM-signed. Microsoft now lets admins block direct send entirely (Set-OrganizationConfig -RejectDirectSend $true in Exchange Online PowerShell), which is worth doing once nothing depends on it.

Exchange hybrid or on-premises servers

If some mail still leaves from an on-premises Exchange server directly, its public IP address must be in SPF, and it won't have Microsoft's DKIM signature unless it routes outbound mail through Exchange Online.

Third-party services

Marketing, CRM, helpdesk and billing services that send as your domain each need their own DKIM setup for your domain, done in that service. Microsoft's DKIM covers only mail that goes through Exchange Online.

Dynamics 365 and other Microsoft services

Some Microsoft products, such as Dynamics 365 Customer Insights, send marketing email from their own infrastructure with separate authentication settings. Set up domain authentication in that product too.

Troubleshooting

"CNAME record does not exist" when enabling DKIM

The records aren't visible yet, are misspelled, or your DNS host appended the domain twice (creating selector1._domainkey.example.com.example.com). Check with the DKIM checker, fix the name, and wait for the TTL to pass.

No DKIM signature, or one for onmicrosoft.com only

Signing for your domain isn't enabled yet, or the message came from a different domain in the tenant. Check the domain's status in the Defender portal: it should show the toggle as Enabled and the status as Valid or "Signing DKIM signatures for this domain". A status of CnameMissing means Microsoft can't see your CNAME records.

DMARC fails for mail forwarded by Outlook rules

Forwarding breaks SPF, so forwarded mail depends on DKIM. Once DKIM is enabled for your domain, forwarded messages usually pass.

Mail from your own domain lands in Junk internally

Usually a sign that something sends as your domain from outside Microsoft 365 without passing SPF or DKIM: an app, a website form, or a service you forgot. Check the message's headers; Microsoft's Authentication-Results header includes a compauth result that explains its decision.

Frequently asked questions

Do I need DKIM if SPF already passes?

Yes. SPF fails when a message is forwarded, and DMARC enforcement then blocks it. DKIM for your own domain is what keeps forwarded mail passing, and Google, Yahoo and Microsoft expect bulk senders to have both.

Does Microsoft 365 set up DMARC for me?

Not for custom domains. You publish the DMARC record at your DNS host. Microsoft 365 checks DMARC on mail it receives and sends reports to other domains' report addresses.

Should I protect the onmicrosoft.com domain too?

Your .onmicrosoft.com domain's DNS is managed by Microsoft. If you never send from it, there's nothing to do; if you do, Microsoft provides a way to add a DMARC record for it in the admin center.

What key size does Microsoft use?

Check with the DKIM checker (selector selector1 or selector2). If it shows a 1024-bit key, rotate to 2048-bit with Rotate-DkimSigningConfig -Identity example.com -KeySize 2048; the new key takes effect after about four days.

I have several domains in the tenant. Do I repeat this?

Yes. SPF, DKIM and DMARC are per domain. Each custom domain needs its own SPF record, its own two DKIM CNAMEs with signing enabled, and its own DMARC record.

Tools for this guide

Keep reading

How to set up DMARC, step by stepFrom your first record to p=reject, without blocking your own email.8 min read · Updated November 29, 2026SPF, DKIM and DMARC for Google WorkspaceSet up email authentication for your domain in Google Workspace and Gmail, step by step.7 min read · Updated November 29, 2026SPF, DKIM and DMARC explainedHow the three email authentication standards work together, and why you need all three.8 min read · Updated November 29, 2026