Configuring SPF for Microsoft 365 Without Breaking It: The 10-Lookup Limit Nobody Checks
An incorrect or missing SPF record is one of the most common reasons legitimate Microsoft 365 email gets marked as spam or rejected outright by receiving mail servers. Configuring it correctly is straightforward, but there are a handful of details, particularly around DNS lookup limits when you use multiple email services, that trip up otherwise correct configurations. Here is how to set it up properly and avoid the mistakes that cause SPF to silently stop protecting your domain.
What SPF actually does and why it matters
Sender Policy Framework is a DNS TXT record that tells receiving mail servers which hosts are authorized to send email on behalf of your domain. Without a correct SPF record, external recipients see an “SPF fail” or “SPF none” result in message headers, and mailbox providers, Gmail and Yahoo in particular, increasingly reject or quarantine mail that fails SPF rather than just flagging it. This isn’t a minor deliverability nuisance anymore, it can mean legitimate business email simply never arrives.
The correct base record for Microsoft 365
v=spf1 include:spf.protection.outlook.com -all
Breaking this down: v=spf1 declares the SPF version in use. include:spf.protection.outlook.com authorizes Microsoft’s own outbound mail infrastructure to send on your domain’s behalf, this is the value that actually matters for Microsoft 365 specifically. The trailing -all is a hard fail, telling receiving servers to reject mail from any source not explicitly authorized in the record. Some guidance recommends a softer ~all (soft fail) during initial rollout or testing, but -all is the stronger setting once you’ve confirmed every legitimate sending source is properly included. Microsoft’s own SPF setup article recommends -all for Microsoft 365 domains, because DMARC treats both as an SPF failure but effectively ignores a ~all failure when the message also has no DKIM signature.
Adding other services without breaking anything
Most real organizations send mail through more than just Microsoft 365, marketing platforms, transactional email services, CRM systems. Each needs its own include statement in the same record, since a domain can only have one SPF record and DNS providers will reject or ignore a second one:
v=spf1 include:spf.protection.outlook.com include:sendgrid.net include:spf.mandrillapp.com ~all
Get the exact include value from each service’s own documentation, not from a generic template, since these values are specific to each provider and do occasionally change.
The DNS lookup limit that silently breaks SPF
This is the detail that causes real, hard-to-diagnose problems. SPF has a hard limit of 10 DNS lookups per evaluation, defined in RFC 7208 section 4.6.4, not a Microsoft-specific limit. Each include:, a, mx, exists and redirect costs one lookup, nested includes add more, and ip4: and ip6: entries cost nothing, as Microsoft lists in Set up SPF for your Microsoft 365 domain.
An older version of this post said Microsoft’s include costs 2 to 3 lookups. I checked it again from my own server with dig in November 2026, and that is not true today. spf.protection.outlook.com is a flat list of IPv4 and IPv6 ranges with no nested include, so it costs exactly one lookup:

The other services are where the budget goes. For the example record above I followed each include the same way. SendGrid has a nested include:ab.sendgrid.net, so it costs two lookups. Mandrill is flat and costs one. That record is 1 + 2 + 1 = 4 lookups out of 10, which is fine. The trouble starts with five or six services, each with nested includes.

Provider records change, so redo this count whenever you add a service. Don’t trust a number from a blog post, including this one.
When an SPF record exceeds the 10-lookup limit, the result is a “permerror,” and many receiving mail servers treat a permerror the same as an outright SPF failure, meaning your domain’s email authentication silently stops working even though the record itself looks syntactically correct. This is worth checking explicitly, not assuming:
# Check your domain's current SPF record directly
nslookup -type=TXT yourdomain.com
# On Linux or macOS, follow each include by hand
dig +short TXT yourdomain.com
# Several free online SPF validators will also count lookups explicitly
# and flag if you're approaching or exceeding the 10-lookup limit,
# worth running any time you add a new service to the record
If you’re approaching the limit, flattening some includes into their actual IP ranges (where the provider supports this) or removing services genuinely no longer in use are the two practical ways to bring a record back under the limit. Microsoft also suggests moving bulk mail services to a subdomain such as marketing.contoso.com, which gets its own 10 lookup budget. Don’t flatten spf.protection.outlook.com itself. Microsoft says its sending IP addresses change frequently.
SPF alone is not enough
SPF verifies the sending server, but it doesn’t verify message content wasn’t altered in transit and doesn’t protect against display-name spoofing on its own. Configure DKIM (which cryptographically signs outbound messages) alongside SPF, then publish a DMARC record that tells receiving servers how to handle messages that fail both. Start DMARC with a monitoring-only policy (p=none) to observe real traffic without risking legitimate mail being rejected, then move toward p=quarantine and eventually p=reject once you’ve confirmed every legitimate sending source is properly covered by SPF and DKIM.
Frequently asked questions
I updated my SPF record but recipients still report SPF failures. Why?
DNS changes take time to propagate, and receiving servers may cache the old record for a period after your update. Confirm the change actually published correctly with a direct DNS query first, then allow for propagation time before troubleshooting further. If failures persist well beyond normal propagation time, recheck for a syntax error or the 10-lookup limit being exceeded, both are more common causes of persistent failures than propagation delay.
Can I have more than one SPF (TXT) record for redundancy?
No, and this is a common, genuinely harmful mistake. Having multiple SPF records (multiple TXT records starting with v=spf1) causes SPF validation to fail entirely for many receiving servers, since the specification only permits one. If you need to authorize multiple services, add multiple include statements within a single record, not multiple separate records.
Does moving to Microsoft 365 automatically create the SPF record for me?
Only for the contoso.onmicrosoft.com domain, which Microsoft owns and manages. For your own custom domain, the Microsoft 365 domain setup asks you to add the SPF record, but you create it at your DNS host and you maintain it after that. There is no portal page or PowerShell cmdlet in Microsoft 365 that edits it, per the Microsoft Learn SPF article. Records added during a busy migration and never touched again are where I see most of the mistakes, so check yours with a direct DNS query.
Sources
- Set up SPF to identify valid email sources for your Microsoft 365 domain (Microsoft Learn)
- Troubleshoot email authentication in Microsoft 365 (Microsoft Learn)
- Set up DKIM (Microsoft Learn)
- Set up DMARC (Microsoft Learn)
- RFC 7208, Sender Policy Framework, section 4.6.4 DNS lookup limits (IETF)
What I checked: the live SPF records of the Microsoft 365, SendGrid and Mandrill includes with dig from an Ubuntu 24.04 server in November 2026. What I did not test: delivery to Gmail or Yahoo with a record over the limit.
