Microsoft 365
How to set up SPF, DKIM and DMARC for Microsoft 365
Set up SPF, DKIM and DMARC for a custom domain in Microsoft 365: the SPF include, the two DKIM CNAMEs and a careful path to p=reject.
Check your current setup:
Step by step, by protocol
Microsoft 365 SPF Record: Set Up SPF in Office 365
The Microsoft 365 SPF record is a TXT record with include:spf.protection.outlook.com. Publish it at your DNS host, merge old records and test it.
Office 365 DKIM setup: enable signing in Microsoft 365
Office 365 DKIM setup: publish two selector CNAME records, turn on signing in the Microsoft Defender portal and confirm dkim=pass in a test message.
Setup DMARC Office 365: step by step on Microsoft 365 domains
Set up DMARC in Office 365: add a _dmarc TXT record at your DNS host, start with p=none, read the reports, then move to quarantine and reject with care.
How the three fit together
To set up SPF, DKIM and DMARC for Microsoft 365, you publish two TXT records and two CNAME records at your DNS host. Then you turn on one switch in the Microsoft Defender portal. Each standard checks something different, and DMARC depends on the other two.
- SPF (Sender Policy Framework) lists the servers allowed to send for a domain. Receivers check that list against the MAIL FROM address, the hidden envelope sender that mail servers use between themselves. Microsoft 365 has no admin screen for SPF, so you publish a TXT record at your DNS host.
- DKIM (DomainKeys Identified Mail) adds a signature to each message. Microsoft keeps the private keys. Your DNS points to the public keys through two CNAME records, and you turn signing on in the Defender portal.
- DMARC (Domain-based Message Authentication, Reporting and Conformance) asks whether SPF or DKIM passed for a domain that aligns with the From address people see. Aligned means the two domains match, by default at the organizational domain level. DMARC also sets a policy and an address for reports. It is another TXT record at your DNS host.
A message passes DMARC when SPF or DKIM passes and that domain aligns with From. In normal Microsoft 365 mail flow, SPF aligns. DKIM still matters because forwarding breaks SPF, and a signature can survive forwarding. Set them up in this order: SPF, DKIM, DMARC.
Before you start
- Add and verify your custom domain in Microsoft 365. DKIM signing works only for a domain you already added.
- Get access to the domain's DNS records at your registrar or DNS host.
- Sign in to the Microsoft Defender portal with an account that can manage email authentication settings. For DKIM, Exchange Online PowerShell is the alternative.
- List every service that sends mail as your domain, such as a CRM or invoicing tool. Each one needs its own setup, because the Microsoft include covers only Microsoft's servers.
SPF: authorize Microsoft 365
Find the TXT record at your root domain that starts with v=spf1. A domain can have only one. If none exists and Microsoft 365 is your only sender, publish this:
v=spf1 include:spf.protection.outlook.com -all
That value is for worldwide and GCC tenants. GCC High and DoD use include:spf.protection.office365.us. Microsoft 365 operated by 21Vianet uses include:spf.protection.partner.outlook.cn.
If a record already exists, add the include to it and keep one record. Before you use -all, also add every other service and on-premises server that sends as your domain. -all tells receivers that unlisted sources are not authorized. Microsoft recommends it when DKIM and DMARC are also in place. If you do not know every source yet, Microsoft's overview suggests starting with ~all (soft fail) and moving to -all once you have found them all.
A subdomain used as SMTP MAIL FROM or HELO needs its own SPF policy; an arbitrary visible From subdomain alone does not decide the SPF lookup. See SPF for Microsoft 365 for the full steps.
DKIM: sign with your own domain
Microsoft 365 signs mail from the initial *.onmicrosoft.com domain automatically. A custom domain needs setup. Microsoft's DKIM article says no signing occurs for custom domains until you set it up. Its New-DkimSigningConfig reference says those messages get the *.onmicrosoft.com signature instead. Neither result aligns with a From address at example.com.
Microsoft 365 uses two selectors, selector1 and selector2. A selector is the name of the DNS record that leads to a DKIM public key. Only one is active at a time, and the other is used after a key rotation. Publish both as CNAME records at these hosts:
selector1._domainkeyselector2._domainkey
Copy the targets Microsoft gives you. New custom domains use a format introduced in May 2025. It looks like selector1-example-com._domainkey.example.n-v1.dkim.mail.microsoft, and Microsoft assigns the letter n. Existing custom domains and initial domains keep selector1-example-com._domainkey.example.onmicrosoft.com. The two formats cannot coexist for the same selector.
In the Defender portal, go to Email & collaboration > Policies & rules > Threat policies > Email authentication settings and open the DKIM tab (direct link). Slide the toggle for your domain. If the status is NoDKIMKeys, the attempt opens a Client error dialog with the values, and the status becomes CnameMissing. Open the domain's details and copy the values from Publish CNAMEs. After you create the records, turn on Sign messages for this domain with DKIM signatures.
With signing on, messages carry d=example.com, which aligns with your From address. DKIM can then pass DMARC on its own. See DKIM for Microsoft 365 for the full steps.
DMARC: publish a policy and collect reports
Check the host _dmarc first. A name can have only one DMARC record, so if one already exists, edit it and keep its current policy and add your rua address. If none exists, create one TXT record with the host _dmarc:
Use this starter value only if no DMARC policy exists at this name. Otherwise edit the existing record, preserving its p=, alignment settings and report addresses; add your monitored rua destination there. Never create a second policy record.
v=DMARC1; p=none; rua=mailto:dmarc@example.com
p=none asks receivers for no special action. rua is the address for aggregate reports, the XML summaries of who sends as your domain. RFC 9990 defines them. Replace the example with your DMARC Pulse reporting address so the reports reach your dashboard.
For a custom domain, this record lives at your DNS host. Microsoft 365 has no portal or cmdlet for it. See DMARC for Microsoft 365 for the full steps.
Moving to enforcement
Read the reports before you change the policy. Confirm that Microsoft 365 and every other sender pass with alignment. Then change p=none to p=quarantine, monitor again and consider p=reject. Microsoft advises starting with a low-volume domain or subdomain and saving the parent domain for last. Its rollout article aims for p=reject and sets no fixed waiting period.
RFC 9989, the current DMARC standard, advises against p=reject for domains whose users post to mailing lists. If such a domain still wants p=reject, section 7.4 says to watch reports at p=none for at least a month, then at p=quarantine for an equally long period. The same section requires valid DKIM signatures on any domain that publishes p=reject.
Microsoft's rollout article still uses pct= for gradual steps. RFC 9989 removed that tag and added t=y, a test mode that asks receivers to apply one level below the published policy. Microsoft's article does not mention t=. Moving p= one level at a time needs neither tag.
At p=quarantine or p=reject, Microsoft 365 routes outbound mail that fails DMARC at the destination through its high-risk delivery pool, and no override exists. Many email organizations do not accept messages from that pool, so clear failures before you tighten the policy.
Common problems
-
The toggle shows
Client error. On the first attempt this is expected, and the dialog carries the CNAME values. Open the domain's details and copy them from Publish CNAMEs. -
The status stays
CnameMissing. Microsoft has not detected the records yet. Enter onlyselector1._domainkeyas the host, because many DNS panels append your domain. Copy the target instead of typing it. Publish CNAME records, since a TXT record will not work here. On Cloudflare, set the records to DNS only. On Amazon Route 53, add a trailing dot to the target. DNS changes can take up to 48 hours. -
Only one selector exists. Signing can work, but key rotation fails later. Publish both.
-
A test shows
dkim=none. Microsoft omits the signature when sender and recipient are in the same domain or in domains of the same organization. Send your test to a mailbox outside your organization. -
SPF returns
permerror. The usual causes are two SPF records or more than 10 DNS lookups. A bounce may readThe message required too many lookups.orThe message exceeded the hop count.Merge the records, or move other services to subdomains. Keepinclude:spf.protection.outlook.comas it is. Microsoft says its sending IP addresses change frequently, so replacing the include with a list of IPs is unsafe. -
A CRM or invoicing tool fails DMARC. SPF can pass for the tool's own domain without aligning with yours. Set up DKIM at the tool so it signs with your domain. Microsoft prefers this fix and recommends a subdomain for services you do not control directly.
-
On-premises or hybrid Exchange servers fail SPF. Add the public IP addresses of on-premises servers that send as your domain, using
ip4:orip6:. -
Forwarded mail fails DMARC. Forwarding breaks SPF, and DKIM survives only if the message is unchanged. If a service in front of Microsoft 365 modifies inbound mail, add its signing domain as a trusted ARC sealer on the ARC tab of Email authentication settings. ARC (Authenticated Received Chain) preserves the original authentication results.
-
The
*.onmicrosoft.comdomain has no DMARC record. Microsoft handles its SPF and DKIM. You add DMARC in the Microsoft 365 admin center under Show all > Settings > Domains. If nobody sends from that domain, use Microsoft's value:TXTv=DMARC1; p=reject
-
No reports arrive from Microsoft. Microsoft 365 sends aggregate reports only when the recipient domain's MX record points directly to Microsoft 365. A gateway or hybrid path in front of the recipient stops those reports. It sends no failure reports either, even with a valid
rufaddress.
To confirm your setup, use the SPF checker, DKIM checker and DMARC checker. You can also paste a message's headers into the email header analyzer. In mail received by Microsoft 365, dmarc=bestguesspass means the domain has no DMARC record.