Guide
Set up SPF, DKIM and DMARC for Microsoft 365
The MX, SPF, DKIM and DMARC records Microsoft 365 needs, and how to turn on DKIM in the Defender portal.
Updated
To send and receive mail as your own domain with Microsoft 365, your domain’s DNS needs four kinds of record: MX so mail reaches Microsoft 365, SPF to say Microsoft 365 may send as you, DKIM so Microsoft 365 can sign your mail, and DMARC to tell receivers what to do with mail that fails. Microsoft 365 lists the records it wants under Microsoft 365 admin center → Settings → Domains → your domain → DNS records.
The examples use example.com: put your own domain in its place. In the Name column, @ means the domain itself; some DNS hosts want that field left empty instead.
The records at a glance
| Type | Name | Value | Priority |
|---|---|---|---|
| MX | @ | example-com.mail.protection.outlook.com | 0 |
| TXT | @ | v=spf1 include:spf.protection.outlook.com ~all | |
| CNAME | selector1._domainkey | selector1-example-com._domainkey.<your tenant>.onmicrosoft.comShape only: copy yours from Microsoft 365. | |
| CNAME | selector2._domainkey | selector2-example-com._domainkey.<your tenant>.onmicrosoft.comShape only: copy yours from Microsoft 365. | |
| TXT | _dmarc | v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com |
1. Verify the domain
Microsoft asks for a TXT record starting MS=ms followed by numbers to prove you own the domain. Leave it in place.
2. MX: receive mail at Microsoft 365
Delete any MX records left from a previous provider (or from your domain registrar), then add these. Mixing old and new MX records sends some of your mail to the old place.
| Type | Name | Value | Priority |
|---|---|---|---|
| MX | @ | example-com.mail.protection.outlook.com | 0 |
Usually your domain with dashes for dots. Copy the exact value from the admin center: some tenants get a different one.
3. SPF: allow Microsoft 365 to send
Add one TXT record at the domain itself:
v=spf1 include:spf.protection.outlook.com ~all A domain can have only one SPF record. If you already have one, add include:spf.protection.outlook.com to it instead of creating a second, and add the includes
of any other service that sends as you (a newsletter tool, a help desk). The SPF record generator builds the combined record and counts its
lookups.
4. DKIM: sign your mail
- Sign in to the Microsoft Defender portal (security.microsoft.com).
- Go to Email & collaboration → Policies & rules → Threat policies → Email authentication settings, and open the DKIM tab.
- Select your domain. If it offers Create DKIM keys, click it.
- Copy the two CNAME records it shows (selector1 and selector2) and add them at your DNS host.
- Once they’re live, return to the same page and switch “Sign messages for this domain with DKIM signatures” on.
The CNAME records look like this:
| Type | Name | Value |
|---|---|---|
| CNAME | selector1._domainkey | selector1-example-com._domainkey.<your tenant>.onmicrosoft.comShape only: copy yours from Microsoft 365. |
| CNAME | selector2._domainkey | selector2-example-com._domainkey.<your tenant>.onmicrosoft.comShape only: copy yours from Microsoft 365. |
Microsoft publishes the keys itself and rotates them; your two CNAMEs just point at them. Newer tenants may be shown targets ending in dkim.mail.microsoft instead: use whatever the portal shows.
5. DMARC: decide what happens to forged mail
Add one TXT record named _dmarc:
v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com p=none changes nothing about delivery: it asks receivers to send you reports, so
you can see what sends as your domain. Create the report mailbox first, or use an address you
already read. Once the reports show only mail you recognise passing, move to p=quarantine and then p=reject, as described in moving DMARC to p=reject.
6. Check it works
New records usually show up within minutes, but can take up to an hour or two (longer if you replaced records with a long TTL). Run the email domain health check: it recognises Microsoft 365 from your MX records and lists anything still missing, with the exact record to add. To see a record reach resolvers around the world, use the DNS propagation checker.
Things to watch with Microsoft 365
- Until you turn on DKIM for your own domain, Microsoft signs with your onmicrosoft.com domain, which doesn’t align with DMARC.
- Microsoft also suggests an autodiscover CNAME. It helps Outlook find your mailbox but has nothing to do with deliverability.
Where to add the records
Step-by-step instructions for the record editor at common DNS hosts:
Not sure who hosts your DNS? It’s usually where you bought the domain, unless you moved its name servers. The WHOIS lookup shows the name servers, and the health check names the host for you.
Related tools
All toolsEmail Domain Health Check
SPF, DKIM, DMARC and MX checked together, with a score and a list of fixes.
SPF Record Generator
Pick the services that send your email and get a ready-to-paste SPF record, lookups counted.
DKIM Record Checker
Find DKIM keys under common selectors, or check your own, with key size and problems.
DMARC Record Generator
Choose a policy and where reports go, and get a DMARC record with a safe path to p=reject.
More guides
- Set up SPF, DKIM and DMARC for Google Workspace The MX, SPF, DKIM and DMARC records Google Workspace needs, and where to turn on DKIM in the Admin console.
- Set up SPF, DKIM and DMARC for Zoho Mail The MX, SPF, DKIM and DMARC records Zoho Mail needs, for every Zoho region, and where to add a DKIM key.
- Set up SPF, DKIM and DMARC for Proton Mail The verification, MX, SPF, DKIM and DMARC records Proton Mail needs for a custom domain, and where to copy them.