Setting up SPF, DKIM and DMARC for Microsoft 365
Step by step for a domain on Microsoft 365, from the first SPF record to a DMARC policy of reject, avoiding the mistakes that cause bounces.
In short
Setting up SPF, DKIM and DMARC for Microsoft 365 means publishing one SPF record that includes spf.protection.outlook.com, adding the two DKIM CNAME records shown in the Defender portal and switching on signing, then publishing DMARC at p=none. Once the reports show every legitimate sender passing, move the policy to quarantine and finally to reject.
On this page
If your business email runs on Microsoft 365, three DNS records decide whether your messages are trusted: SPF, DKIM and DMARC. Since February 2024 Google and Yahoo have required them from anyone sending in volume, and Microsoft brought in the same requirement for mail to Outlook.com and Hotmail addresses in May 2025. Even a small firm that sends a handful of invoices a day benefits: a domain without DMARC can be spoofed by anyone, and receivers are quicker to send unauthenticated mail to junk.
This guide takes a domain from nothing to a DMARC policy of p=reject. It assumes the domain is already added and verified in Microsoft 365 and that mail is flowing. Throughout, example.co.uk stands for your domain.
Before you start: make a list of everything that sends email as your domain, not just Outlook. Website contact forms, your accounting package, your CRM, a newsletter platform, a booking system, the office printer that emails scans. Every one of them has to pass SPF or DKIM in its own right before you enforce DMARC, or its mail will start to disappear.
How the three records fit together
#SPF (Sender Policy Framework) is a list of the servers allowed to send mail for a domain. A receiver checks the address the message was sent from at the envelope level – the bounce or Return-Path address, which is often not the one you see in your mail client.
DKIM (DomainKeys Identified Mail) is a cryptographic signature added by the sending server. The receiver fetches a public key from your DNS and checks the signature, which proves the message was not altered and was signed by someone holding your private key.
DMARC ties them to the address people actually see. A message passes DMARC when SPF or DKIM passes and the domain that passed matches the visible From: domain. That matching is called alignment, and it is where most problems hide: a service can pass SPF for its own domain and still fail DMARC for yours.
Of the three, DKIM matters most. SPF breaks whenever a message is forwarded, because the forwarding server is not on your list. A DKIM signature travels with the message and usually survives.
Step 1: Publish one SPF record
#Microsoft 365's outbound servers are covered by a single include. In your DNS host, add a TXT record at the root of the domain (often entered as @):
example.co.uk. TXT "v=spf1 include:spf.protection.outlook.com -all"Three rules catch people out:
- A domain may have only one SPF record. If one already exists – perhaps your web host added
v=spf1 a mx ~allyears ago – merge them into one rather than adding a second. Two SPF records make every SPF check return a permanent error. - Add other senders to the same record, using the include each provider documents, for example
v=spf1 include:spf.protection.outlook.com include:mail.zendesk.com -all. - Stay within ten DNS lookups. Every
include,a,mxandredirectcosts at least one, and includes can contain further includes. Go over ten and SPF returns a permanent error. Our guide to the SPF lookup limit explains how to count and what to do if you are over.
-all tells receivers that anything not listed is unauthorised. ~all (a "soft fail") is a gentler alternative while you are still discovering senders. Once DMARC is enforcing, the difference matters little, because DMARC makes the final decision.
Step 2: Turn on DKIM signing for your domain
#Out of the box, Microsoft 365 does not sign your mail with your own domain. The only automatic signing uses your tenant's onmicrosoft.com domain, and a signature from that domain does not align with example.co.uk, so for DMARC purposes it counts for nothing. You need to switch on signing for your own domain.
- Sign in to the Microsoft Defender portal and go to Email & collaboration → Policies & rules → Threat policies → Email authentication settings, then open the DKIM tab.
- Select your domain. If DKIM is not yet set up, choose Create DKIM keys and the details pane then shows two CNAME records to publish, named
selector1._domainkeyandselector2._domainkey. - Create both CNAME records at your DNS host, copying the target values exactly as the portal shows them. For domains added before May 2025 they end in
onmicrosoft.com; domains added since then get targets ending indkim.mail.microsoft. Do not try to construct them yourself. - Wait for the records to be visible – usually minutes, occasionally a few hours – then return to the portal and turn on Sign messages for this domain with DKIM signatures.
Using CNAMEs means Microsoft holds the private keys and can rotate them for you. The portal's Rotate DKIM keys button switches between selector1 and selector2, which is why both records must exist.
To confirm the records are live, enter your domain in our DMARC & DKIM Checker, which probes both Microsoft selectors automatically and reports the key length behind them.
A common snag: the DNS panel adds your domain twice
Many DNS control panels append your domain to whatever you type in the name field. Typing selector1._domainkey.example.co.uk then creates selector1._domainkey.example.co.uk.example.co.uk, and the portal will never find it. Enter just selector1._domainkey and check the result with a DNS lookup for the CNAME.
Step 3: Publish DMARC in monitoring mode
#Start with a policy that changes nothing for delivery but asks receivers to send you daily reports. Add a TXT record named _dmarc:
_dmarc.example.co.uk. TXT "v=DMARC1; p=none; rua=mailto:dmarc-reports@example.co.uk"The rua address receives aggregate reports: XML files, one per receiver per day, listing every IP address that sent mail claiming to be you and whether it passed. They arrive in volume, so use a dedicated mailbox or a free report-processing service rather than your own inbox. If the address is on a different domain from the one being reported on, that domain must publish an authorisation record; hosted DMARC services do this for you.
Our DMARC generator builds this record, and will load your live record later so you can see exactly what changes when you tighten the policy.
Step 4: Read the reports and fix every legitimate sender
#Give it two to four weeks so that monthly jobs – payroll, statements, renewal reminders – have a chance to appear. Then work through the senders in the reports. Each falls into one of four groups:
| What you see | What it means | What to do |
|---|---|---|
| Microsoft IPs, DKIM pass, aligned | Your Outlook mail, working correctly | Nothing |
| A service you use, SPF or DKIM pass but not aligned | It authenticates as its own domain, not yours | Set up the provider's "domain authentication" (usually DKIM CNAMEs) for your domain |
| A service you use, failing both | Not configured at all | Add its SPF include and its DKIM records, or move it to a subdomain |
| IP addresses you do not recognise, failing both | Usually spoofing – exactly what DMARC exists to stop | Nothing; enforcement will deal with it |
The second row is the one that bites. Newsletter and CRM platforms commonly send with their own bounce domain, so SPF passes – for them. Adding their include to your SPF record does not help, because SPF is checked against their domain, not yours. What makes them align is DKIM signing with your domain, which every reputable platform supports under a name such as "authenticate your domain" or "custom sending domain".
Our guide to reading DMARC aggregate reports walks through the XML field by field.
Step 5: Move to quarantine, then reject
#When the reports show only your known senders passing, and the failures are all strangers, tighten the policy. A cautious path is to publish quarantine in testing mode first:
v=DMARC1; p=quarantine; t=y; rua=mailto:dmarc-reports@example.co.ukThe t=y flag asks receivers to apply one step less than the stated policy, so failing mail is still delivered while the reports show what quarantine would catch. It was introduced by RFC 9989, the 2026 replacement for the original DMARC specification (RFC 7489), which also removed the older pct percentage tag; a receiver that has not adopted the new specification ignores t=y and quarantines failing mail straight away. Keep an eye on the reports and on any complaints of missing mail, then remove t=y, leave quarantine in place for at least a month, and finally move to reject:
v=DMARC1; p=reject; rua=mailto:dmarc-reports@example.co.ukAt p=reject, you ask receivers to refuse mail that fails DMARC outright; the final decision is theirs, and Gmail and Microsoft 365 both reject such mail. Spoofed invoices and fake "change of bank details" messages sent in your name stop reaching anyone who checks DMARC – which today means nearly every major mailbox provider.
One caution before the last step. RFC 9989 says that domains whose users post to mailing lists should not publish p=reject: a list usually alters a message in ways that break its DKIM signature, and subscribers' mail servers then refuse it, which can get those subscribers removed from the list. If your staff take part in external mailing lists, stopping at p=quarantine is a reasonable final policy.
If you never send mail from subdomains, it is also worth adding sp=reject so that made-up subdomains such as billing.example.co.uk cannot be abused either.
Checking that it works
#Send a message from Outlook to a Gmail address, open it, and choose Show original. Gmail summarises the result at the top: you want PASS for SPF, DKIM and DMARC, and the DKIM line should mention example.co.uk, not your onmicrosoft.com domain. In Outlook, the same information is in the message headers under Authentication-Results.
For an at-a-glance view of all three records, run your domain through the DMARC & DKIM Checker. It grades the setup, explains each tag in plain English, and flags the common mistakes covered here.
Quick reference
#| Record | Type | Name | Value |
|---|---|---|---|
| SPF | TXT | @ | v=spf1 include:spf.protection.outlook.com -all (plus your other senders) |
| DKIM | CNAME | selector1._domainkey | Copied exactly from the Defender portal |
| DKIM | CNAME | selector2._domainkey | Copied exactly from the Defender portal |
| DMARC | TXT | _dmarc | Start at v=DMARC1; p=none; rua=mailto:…, finish at p=reject |