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
-
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.
-
Check for an existing record. Run the SPF checker and look for a record that starts with
v=spf1. -
Pick the value for your cloud.
Microsoft 365 and its GCC government cloud:
TXTv=spf1 include:spf.protection.outlook.com -all
GCC High and DoD government clouds:
TXTv=spf1 include:spf.protection.office365.us -all
Microsoft 365 operated by 21Vianet:
TXTv=spf1 include:spf.protection.partner.outlook.cn -all
-
Merge if a record already exists. Add the
include:to it and keep its other values. For example, with an on-premises server:TXTv=spf1 ip4:203.0.113.10 include:spf.protection.outlook.com -all
Caution: never add a second
v=spf1record. Two records on one name make SPF returnpermerror, a permanent error. -
Choose the ending. Microsoft recommends
-all, which returns SPF fail for unlisted sources.~allreturns softfail while you inventory legitimate senders. The receiver decides delivery; RFC 7208 says not to reject solely on softfail. Move to-allafter authorizing every source using this SPF domain. -
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.
- Run the SPF checker again. Expect one
v=spf1record, your cloud'sinclude:and no more than 10 DNS lookups. - On the Domains page, read the Status column. If it shows an issue, open the three dots and select Check health.
- Send a message to another organization and open the headers. A recipient on Microsoft 365 sees
spf=passandsmtp.mailfrom=with your domain in Authentication-Results. Other providers may format this differently.
Common problems
spf=permerrorin the headers. Microsoft's troubleshooting table lists multiple SPF records or more than 10 DNS lookups. Its docs also name aninclude: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 readThe message exceeded the hop count.orThe message required too many lookups.When we resolvedspf.protection.outlook.com, it held onlyip4:andip6: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.23bounces. 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.