# Set Up SPF, DKIM and DMARC in Microsoft 365

URL: https://email-validation.org/guides/microsoft-365-spf-dkim-dmarc/
Updated: 2026-11-30

> Documentation index: https://email-validation.org/llms.txt

To authenticate mail from your own domain in Microsoft 365, you publish three things at your DNS host: one SPF TXT
record that includes `spf.protection.outlook.com` (in the commercial cloud and GCC; other Microsoft clouds use other
values, see [step 1](#spf)), two DKIM CNAME records whose exact targets Microsoft generates for your domain, and a
DMARC TXT record at `_dmarc`. You create SPF and DMARC where your domain's DNS is hosted: at your registrar or DNS
host, or in the Microsoft 365 admin center only if Microsoft 365 hosts that DNS zone. DKIM signing for a custom domain is also off until you turn it on in
the Defender portal. This guide walks through the steps as Microsoft documents them.

## Before you start

- **The `*.onmicrosoft.com` domain is already done.** Microsoft maintains SPF for it and DKIM-signs its mail
  automatically. It still needs a DMARC record, which you add in the Microsoft 365 admin center.
- **Each sending subdomain needs its own records.** The SPF record for `contoso.com` doesn't cover
  `marketing.contoso.com`, and each subdomain you send from needs its own DKIM configuration. DMARC is different: a
  subdomain without its own DMARC record inherits the parent domain's.
- **Use a subdomain for services you don't control.** Microsoft recommends sending bulk mail from services such as an
  email marketing platform from a subdomain, so their problems don't affect the reputation of your main domain.

## Step 1: SPF

Microsoft's [SPF article](https://learn.microsoft.com/en-us/defender-office-365/email-authentication-spf-configure)
gives this record for a domain whose only source of mail is Microsoft 365 (commercial cloud and GCC):

```text
v=spf1 include:spf.protection.outlook.com -all
```

GCC High, DoD and the cloud operated by 21Vianet use other values, listed in
[the same article's examples](https://learn.microsoft.com/en-us/defender-office-365/email-authentication-spf-configure#examples-spf-txt-records).
If other systems also send as your domain, add their `ip4:`, `ip6:` or `include:` values to that same record. The
rules Microsoft lists:

- **One SPF record per domain or subdomain.** Two records make SPF return `permerror`.
- **`-all` is recommended** for Microsoft 365 domains, because Microsoft also recommends DKIM and DMARC.
- **At most 10 DNS lookups.** `include:`, `a`, `mx`, `exists` and `redirect` each count; `ip4:`, `ip6:` and `all` do
  not, and nested includes add more ([the SPF lookup limit](https://email-validation.org/guides/spf-lookup-limit/)). Microsoft advises against
  flattening its own include, because its sending IP addresses change frequently.
- **TTL of at least 3600 seconds** (one hour), to avoid DNS lookup timeouts.

## Step 2: DKIM

Microsoft's [DKIM article](https://learn.microsoft.com/en-us/defender-office-365/email-authentication-dkim-configure)
says no DKIM signing occurs for outbound mail from a custom domain until you configure it. The steps:

1. In the Defender portal, open **Email & collaboration > Policies & rules > Threat policies > Email authentication
   settings** (or go to `https://security.microsoft.com/authentication`) and select the **DKIM** tab.
2. Try to switch the custom domain's toggle to **Enabled**. An error dialog appears; close it. The domain's status is
   now **CnameMissing**.
3. Open the domain's details and copy the two values under **Publish CNAMEs**.
4. At your DNS host, create two CNAME records, `selector1._domainkey` and `selector2._domainkey`, pointing to those
   values.
5. After Microsoft detects them (a few minutes or longer), turn on **Sign messages for this domain with DKIM
   signatures**.

Copy the targets rather than typing them. Microsoft introduced a new target format for new custom domains in May 2025,
ending in `dkim.mail.microsoft` with a character it assigns to your domain, while existing domains keep the older
format under `onmicrosoft.com`. The two formats can't coexist for the same selector. In Exchange Online PowerShell,
`Get-DkimSigningConfig -Identity <domain> | Format-List Name,Enabled,Status,Selector1CNAME,Selector2CNAME` shows the
exact values. Only one selector signs at a time; the other is used after a key rotation
([DKIM selectors and key rotation](https://email-validation.org/guides/dkim-selectors-key-rotation/)).

## Step 3: DMARC

Microsoft's [DMARC article](https://learn.microsoft.com/en-us/defender-office-365/email-authentication-dmarc-configure)
says a message passes DMARC if SPF or DKIM passes with a domain aligned to the From address, and fails only if both
fail. It recommends a gradual rollout, starting with a low-volume domain or subdomain and leaving the parent domain for
last:

1. Publish a TXT record at `_dmarc` with `p=none` and a `rua=mailto:` address for aggregate reports, and watch the
   reports ([reading aggregate reports](https://email-validation.org/guides/dmarc-aggregate-reports/)).
2. Move to `p=quarantine` once the reports show your legitimate mail passes.
3. Move to `p=reject`.

A starting record looks like this (use a mailbox you read, ideally a shared mailbox or group rather than a person's):

```text
v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com
```

Microsoft's examples still include `pct=` for a percentage rollout. RFC 9989, which replaced RFC 7489 in May 2026,
removed the `pct` tag, so don't count on receivers applying a percentage
([moving from p=none to p=reject](https://email-validation.org/guides/dmarc-none-to-reject/)).

Two Microsoft details worth knowing: outbound mail from a Microsoft 365 domain with `p=quarantine` or `p=reject` that
fails DMARC at the destination is routed through Microsoft's high-risk delivery pool, and Microsoft 365 sends DMARC
aggregate reports for inbound mail only when the receiving domain's MX record points directly to Microsoft 365.

## Step 4: test

Send a message from each system that uses your domain to a mailbox you control outside your organization, and read
its `Authentication-Results` header. Check that `spf` or `dkim` passes, that `smtp.mailfrom` or `header.d` shares the
From domain's organizational domain, and that `dmarc=pass`. Microsoft's article walks through a header where SPF and
DKIM both pass for a vendor's domain but DMARC fails because neither aligns with the From address.

## Questions

### Can I manage SPF or DMARC records in the Microsoft 365 admin center?

Only if Microsoft 365 hosts your domain's DNS: then you add TXT records under **Settings > Domains > DNS records**.
Otherwise you create them at your domain registrar or DNS host; Microsoft's SPF article says there are no admin
portals or PowerShell cmdlets in Microsoft 365 to manage them there. The DMARC record of the `*.onmicrosoft.com`
domain is added in the admin center.

### What should I publish for a domain that never sends mail?

Microsoft's articles give `v=spf1 -all` as the SPF record and `v=DMARC1; p=reject;` as the DMARC record for a parked
domain, and recommend no DKIM records for it.

### Does `~all` work as well as `-all`?

DMARC treats both as SPF failures, but Microsoft notes that the DMARC policy is effectively ignored for `~all`
failures on messages without DKIM signatures, which is why it recommends `-all`.

## Try it

Check your records with the free [SPF checker](https://email-validation.org/tools/spf-checker/), [DKIM checker](https://email-validation.org/tools/dkim-checker/) and
[DMARC checker](https://email-validation.org/tools/dmarc-checker/).

## Related

- [Outlook.com sender requirements](https://email-validation.org/guides/outlook-sender-requirements/): what Microsoft's consumer mailboxes expect
  from bulk senders.
- [Glossary: DMARC policy](https://email-validation.org/glossary/#dmarc-policy).

## Related guides

- [Outlook.com requirements for high-volume senders](https://email-validation.org/guides/outlook-sender-requirements/)
- [Moving DMARC from p=none to p=reject](https://email-validation.org/guides/dmarc-none-to-reject/)
- [The SPF 10-lookup limit explained](https://email-validation.org/guides/spf-lookup-limit/)
- [DKIM selectors and key rotation](https://email-validation.org/guides/dkim-selectors-key-rotation/)
- [How to read DMARC aggregate reports](https://email-validation.org/guides/dmarc-aggregate-reports/)
- [All guides](https://email-validation.org/guides/)

## Sources

- [Microsoft Learn: Set up SPF for your Microsoft 365 domain](https://learn.microsoft.com/en-us/defender-office-365/email-authentication-spf-configure):
  the record, one record per domain, `-all`, the 10-lookup limit, TTL and flattening.
- [Microsoft Learn: How to use DKIM for email in your custom domain](https://learn.microsoft.com/en-us/defender-office-365/email-authentication-dkim-configure):
  the Defender portal steps, CnameMissing, the CNAME formats and `Get-DkimSigningConfig`.
- [Microsoft Learn: Set up DMARC to validate email in Microsoft 365](https://learn.microsoft.com/en-us/defender-office-365/email-authentication-dmarc-configure):
  alignment, the rollout, reports, the high-risk delivery pool and parked domains.
- [RFC 9989](https://www.rfc-editor.org/info/rfc9989/): DMARC, replacing RFC 7489; the `pct` tag removed.

_How we wrote this: drafted by the email-validation.org team with the help of AI writing tools, from our product documentation and the sources linked in the text._

## Get up to 500 free credits. No card needed.

New accounts get 500 free credits (100 when you sign up with a free email provider such as Gmail, Outlook or Yahoo, another personal mailbox such as a paid one like Fastmail or one from your internet provider, or an address from a relay or alias service). Try it on your own list before you buy. [Create your account](https://email-validation.org/signin/?new=1) or [open the free email checker](https://email-validation.org/email-checker/).
