Skip to content
DMARC Pulse

Microsoft 365

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.

Before you start

The Microsoft 365 SPF record is one TXT record at the root of your custom domain, and for standard Microsoft 365 its value is v=spf1 include:spf.protection.outlook.com -all. Microsoft says there are no admin portals or PowerShell cmdlets for managing it, so you create the record at your DNS host.

You need:

  • DNS access. A login that can edit records at your registrar or DNS hosting provider. Changing the domain inside Microsoft 365 itself requires the Domain Name Administrator role.
  • A list of every sender. Exchange Online, on-premises servers, scanners, apps and marketing tools.
  • The right domains. Microsoft maintains the record for onmicrosoft.com, and you can't change it. Each custom domain or subdomain you send from needs its own record.

Steps

  1. Find your DNS host. In the Microsoft 365 admin center, go to Show all > Settings > Domains, select the domain and open DNS records. If + Add records isn't available, a non-Microsoft registrar hosts the domain and the page names it. Otherwise, Microsoft hosts your DNS, and you'll add the TXT record on this page in step 6.

  2. Check for an existing record. Run the SPF checker and look for a record that starts with v=spf1.

  3. Pick the value for your cloud.

    Microsoft 365 and its GCC government cloud:

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

    GCC High and DoD government clouds:

    TXT
    v=spf1 include:spf.protection.office365.us -all

    Microsoft 365 operated by 21Vianet:

    TXT
    v=spf1 include:spf.protection.partner.outlook.cn -all
  4. Merge if a record already exists. Add the include: to it and keep its other values. For example, with an on-premises server:

    TXT
    v=spf1 ip4:203.0.113.10 include:spf.protection.outlook.com -all

    Caution: never add a second v=spf1 record. Two records on one name make SPF return permerror, a permanent error.

  5. Choose the ending. Microsoft recommends -all, which returns SPF fail for unlisted sources. ~all returns softfail while you inventory legitimate senders. The receiver decides delivery; RFC 7208 says not to reject solely on softfail. Move to -all after authorizing every source using this SPF domain.

  6. Save as TXT, TTL 3600. Use host @ for the root or the subdomain label, such as marketing. Follow your DNS host’s name format.

SPF records in the Office 365 setup wizard

Caution: the list includes MX, both when you add the records by hand and with Domain Connect, which adds them automatically. An MX change sends all new mail for the domain to Microsoft 365, so review the list before you add or authorize it. To change only SPF, skip the wizard.

Confirm it worked

Publishing the TXT record activates SPF. Unlike DKIM, it has no switch in Microsoft 365. Microsoft's DNS host guides say a change typically takes about 15 minutes, occasionally longer.

  1. Run the SPF checker again. Expect one v=spf1 record, your cloud's include: and no more than 10 DNS lookups.
  2. On the Domains page, read the Status column. If it shows an issue, open the three dots and select Check health.
  3. Send a message to another organization and open the headers. A recipient on Microsoft 365 sees spf=pass and smtp.mailfrom= with your domain in Authentication-Results. Other providers may format this differently.

Common problems

  • spf=permerror in the headers. Microsoft's troubleshooting table lists multiple SPF records or more than 10 DNS lookups. Its docs also name an include: domain that doesn't resolve or has no SPF record, and a badly formatted record.
  • Too many lookups. Each include: counts and nested ones add more. Bounces can read The message exceeded the hop count. or The message required too many lookups. When we resolved spf.protection.outlook.com, it held only ip4: and ip6: ranges, so it costs one lookup. Microsoft suggests moving other services to subdomains, which have their own limit. Don't flatten this include into fixed IPs: Microsoft says its sending IPs change frequently. See how to fix SPF permerror.
  • 550 5.7.23 bounces. Microsoft ties this code to an SPF configuration issue. Check your record and add any on-premises IPs. Messages routed through its High Risk Delivery Pool also won't pass SPF.
  • Scanners and apps. If a device relays through an IP-based connector, Microsoft says to add that IP to the SPF record.
  • Forwarded mail. Exchange Online rewrites the MAIL FROM (envelope sender) of autoforwarded messages so SPF can pass. That doesn't fix DMARC, which then depends on an intact DKIM signature from your domain. See the DMARC guide too.

Check it now

Validate SPF and count DNS lookups

Frequently asked questions

What is the correct SPF record for Office 365?
For standard Microsoft 365 and GCC, use v=spf1 include:spf.protection.outlook.com -all as a TXT record at the domain root. GCC High and DoD use include:spf.protection.office365.us. Microsoft 365 operated by 21Vianet uses include:spf.protection.partner.outlook.cn. If other systems send for your domain, add them to the same record.
Can I edit the SPF record in the Microsoft 365 admin center?
Usually not. Microsoft says there are no admin portals or PowerShell cmdlets for managing SPF records, and you create the record at your registrar or DNS host. The exception is a domain whose DNS Microsoft 365 hosts: its DNS records page offers + Add records.
Should my O365 SPF record end in -all or ~all?
Microsoft recommends -all, which returns SPF fail for unlisted sources; ~all returns softfail. The receiver decides delivery and should not reject solely on softfail. Inventory legitimate senders before changing the ending.
Can I flatten include:spf.protection.outlook.com?
Microsoft says not to, because its sending infrastructure uses dynamic IP addresses that change frequently. Flattening means replacing an include with fixed IP addresses. Microsoft lists flattening as appropriate for non-Microsoft senders with stable, documented IP ranges.
Do I need an SPF record for my onmicrosoft.com domain?
No. Microsoft owns onmicrosoft.com and maintains its DNS records, so the SPF record is already in place and you can't change it. Only your custom domains need setup.
Do subdomains need their own SPF record in Microsoft 365?
Yes. The record on example.com doesn't cover marketing.example.com, so each subdomain you send from needs its own TXT record. Microsoft recommends a subdomain for email services you don't directly control.

Sources consulted

Related pages

Keep it healthy

Know the moment something breaks

Point your DMARC reports to DMARC Pulse and see who sends email as your domain, what fails and why — with a calm alert when anything changes.

Free plan: 1 domain, no credit card.