Set up SPF, DKIM and DMARC for Microsoft 365
Step-by-step for Exchange Online: the SPF include, the two DKIM CNAME records and how to enable signing in the Defender portal, then a safe first DMARC record.
Want to see where your domain stands before you start? Check your domain
Microsoft 365 (Exchange Online) authenticates your outgoing mail once SPF, DKIM and DMARC are published for your custom domain. The DKIM part is where most setups stall: the DNS records are created but signing is never switched on. This guide covers all three records and the switch.
Before you start
You need:
- A global administrator (or Exchange/Security administrator) account.
- Access to the DNS of your domain.
- A list of every other service that sends mail using your domain, and of any on-premises server or device (printers, scanners, line-of-business apps) that sends directly to the internet.
Run the DMARC, SPF and DKIM checker first to see what already exists.
Step 1: SPF
Microsoft publishes the addresses of Exchange Online under spf.protection.outlook.com.
| Host / Name | Type | Value |
|---|---|---|
@ (the bare domain) |
TXT | v=spf1 include:spf.protection.outlook.com -all |
Rules:
- One record only. If a
v=spf1TXT record exists, edit it. - Add other services’ includes before
-all. Count the lookups with the SPF checker: the limit is 10 and Microsoft’s include already uses several. - An on-premises server that sends directly needs its public IP:
ip4:203.0.113.10. - Microsoft documents
-all;~allis an acceptable softer choice while you are still finding senders.
The Microsoft 365 admin center (Settings → Domains → your domain → DNS records) shows the exact SPF value expected for your tenant.
Step 2: DKIM
Exchange Online uses two selectors, selector1 and selector2, and rotates between them. Each is a CNAME in your DNS pointing to a key Microsoft hosts in your tenant’s onmicrosoft.com domain.
- Open the Microsoft Defender portal: security.microsoft.com → Email & collaboration → Policies & rules → Threat policies → Email authentication settings → DKIM tab.
- Select your custom domain. If the panel says the CNAME records do not exist yet, click Create DKIM keys. The portal displays the two records to publish.
- Publish both CNAMEs. The target names follow this pattern, where your domain’s dots become dashes and
tenantis your initialonmicrosoft.comname:
| Host / Name | Type | Value (as shown in the portal) |
|---|---|---|
selector1._domainkey |
CNAME | selector1-yourdomain-com._domainkey.tenant.onmicrosoft.com |
selector2._domainkey |
CNAME | selector2-yourdomain-com._domainkey.tenant.onmicrosoft.com |
- Wait for the records to propagate, then return to the DKIM panel and switch Sign messages for this domain with DKIM signatures to Enabled. If the portal reports that the CNAMEs are missing, wait longer; it checks them live.
- Verify with the DKIM checker using the selector
selector1,selector2. One of the two selectors shows a key (Microsoft serves only the active one); the other is reported as a CNAME without a key, which is normal.
If you prefer PowerShell, New-DkimSigningConfig -DomainName yourdomain.com -KeySize 2048 -Enabled $true creates the configuration with a 2048-bit key; Rotate-DkimSigningConfig -KeySize 2048 -Identity yourdomain.com upgrades an existing 1024-bit key.
Step 3: DMARC
Start in monitoring mode with a reporting address, so nothing is blocked while you confirm every sender passes.
| Host / Name | Type | Value |
|---|---|---|
_dmarc |
TXT | v=DMARC1; p=none; rua=mailto:dmarc-reports@yourdomain.com |
Create the mailbox or a shared mailbox for the reports. Within a day or two, Microsoft, Google, Yahoo and others start sending XML reports; How to read a DMARC report explains them. Once every legitimate source is aligned, follow From p=none to p=reject.
Note that your tenant.onmicrosoft.com domain is separate: Microsoft handles its DKIM, and a DMARC record for it is optional.
Step 4: Verify with a real message
Send a message to an Outlook.com or Gmail address, then view the headers (Outlook: open the message → File → Properties → Internet headers; Gmail: Show original). Look for the Authentication-Results header:
spf=pass (sender IP is 40.107.x.x) smtp.mailfrom=yourdomain.com;
dkim=pass (signature was verified) header.d=yourdomain.com;
dmarc=pass action=none header.from=yourdomain.com
header.d must be your domain, not tenant.onmicrosoft.com. If it is the onmicrosoft.com domain, DKIM signing for the custom domain is not enabled yet.
Common problems
- CNAMEs created, signing not enabled. The checker reports selector1._domainkey is a CNAME with no key behind it for both selectors. Go back to the Defender portal and enable signing.
- Only one selector serves a key. Expected: Microsoft rotates keys and keeps one selector active.
- Hybrid or on-premises senders. Mail sent directly from an on-premises Exchange server or an application is not signed by Microsoft. Route it through Exchange Online with a connector, or sign it on-premises with your own selector and add the server’s IP to SPF.
- SMTP AUTH client submission. Devices that authenticate against
smtp.office365.comwith a mailbox send through Exchange Online and are covered. Direct Send (unauthenticated, to your own mailboxes only) is not meant for external mail. - Too many SPF lookups.
spf.protection.outlook.complus a CRM, a ticketing tool and a newsletter platform can exceed 10. Move bulk senders to a subdomain with its own SPF record.
Check your work. Run the checker on your domain: it reads the live DNS records and tells you what is still missing.