The 10-lookup limit in SPF records has caused more legitimate email failures than perhaps any other technical constraint in email authentication. Organizations frequently discover this limitation only after their email delivery has already been impacted, making it crucial to understand both the problem and the solutions before issues arise.
Why the 10-Lookup Limit Exists
SPF (Sender Policy Framework) works by allowing domain owners to specify which mail servers are authorized to send email on their behalf. When a receiving mail server gets a message claiming to be from your domain, it checks your SPF record to verify the sending server's authorization.
The lookup limit exists for a practical reason: preventing abuse. Without this constraint, malicious actors could create SPF records that trigger excessive DNS queries, potentially weaponizing the SPF validation process into a distributed denial-of-service attack against DNS infrastructure.
Each mechanism in your SPF record that requires the receiving server to perform an additional DNS lookup counts toward this limit. The mechanisms that trigger lookups are include:, a, mx, exists, and redirect. The ip4 and ip6 mechanisms don't require lookups because they specify addresses directly.
How Lookups Accumulate Quickly
Consider a common scenario for a growing business. You start with a simple SPF record:
v=spf1 mx include:_spf.google.com ~all
This seems straightforward, but let's count the actual lookups. The mx mechanism requires a lookup to find your domain's MX records. If you have two MX records, that's potentially two more lookups to resolve those hostnames to IP addresses. The include:_spf.google.com triggers one lookup, but Google's SPF record itself contains additional includes that count toward your total.
Now you add a marketing email platform:
v=spf1 mx include:_spf.google.com include:spf.emailprovider.com ~all
That provider's SPF record likely includes several more domains, each consuming lookups. Add a CRM system that sends transactional emails, a helpdesk solution, and perhaps a newsletter service, and you've easily exceeded 10 lookups without realizing it.
The Consequences of Exceeding the Limit
When an SPF record exceeds 10 lookups, receiving mail servers are supposed to return a "PermError" result. According to the SPF specification, this should be treated as a failure, equivalent to the mail coming from an unauthorized source.
In practice, the consequences vary. Some receiving servers strictly enforce the limit and reject messages. Others may ignore SPF entirely when encountering this error. A few might process what they can and make a best-effort decision. This inconsistency means you can't predict how different recipients will handle your email, creating an unreliable delivery situation.
Auditing Your Current SPF Record
Before attempting any optimization, you need to understand exactly how many lookups your current record requires. Several online tools can analyze SPF records and count lookups, but you can also perform a manual analysis.
Start by retrieving your SPF record:
For each include: mechanism, retrieve that domain's SPF record and examine it recursively. Track each include:, a, mx, and exists mechanism you encounter. Don't forget that mx mechanisms can trigger multiple lookups if your domain has multiple MX records.
Create a spreadsheet or document listing each service you've authorized and how many lookups it consumes. This inventory becomes your roadmap for optimization.
Strategy One: Replace Includes with IP Addresses
The most straightforward flattening approach involves replacing include: mechanisms with explicit ip4: and ip6:mechanisms. When you replace an include statement with the actual IP addresses it represents, you eliminate all the lookups that include would have triggered.
For example, if include:spf.provider.com resolves to three IP addresses, you can replace it with:
ip4:192.0.2.10 ip4:192.0.2.11 ip4:192.0.2.12
This change reduces your lookup count but introduces a critical maintenance consideration: IP addresses can change. If your email service provider adds new sending servers or retires old ones, your flattened record won't automatically update.
Different services have varying levels of IP address stability. Major platforms like Google Workspace and Microsoft 365 maintain relatively stable IP ranges and provide advance notice of changes. Smaller providers or those using dynamic infrastructure may change addresses more frequently.
Strategy Two: Consolidate Email Services
Sometimes the best optimization isn't technical but organizational. Review each service in your SPF record and ask whether it genuinely needs to send email from your domain.
Many organizations have accumulated email-sending services over time without regular audits. That marketing platform you tested two years ago might still be in your SPF record even though you've moved to a different provider. Development and staging environments sometimes send email from production domains when they should use separate domains.
Each service you can remove from your SPF record immediately reduces your lookup count. This approach requires coordination across teams but provides the most sustainable long-term benefit.
Strategy Three: Use Subdomains for Specific Senders
Creating subdomains for high-volume or automated email senders provides multiple benefits beyond SPF optimization. When you configure a service to send from marketing.yourdomain.com instead of yourdomain.com, that subdomain gets its own SPF record with its own 10-lookup budget.
This approach works particularly well for:
- Marketing and newsletter platforms
- Transactional email services
- Automated notification systems
- Development and staging environments
The subdomain strategy does require updating your email authentication stack. You'll need to configure DKIM signing for the subdomain and establish a DMARC policy. When setting up these subdomains through your domain registrar, ensure they're properly configured with all necessary DNS records for email authentication. Recipients will see emails coming from the subdomain, which may affect branding considerations. However, most users don't closely examine the sending domain in the From address, particularly for transactional or automated messages.
Strategy Four: Dual SPF Records for IPv4 and IPv6
While not technically part of the SPF specification, some organizations have experimented with creating separate SPF-like records for IPv4 and IPv6 traffic. This approach is controversial and not universally supported, so it should be considered only in specific circumstances with careful testing.
The standard approach remains maintaining a single SPF record that covers both address families while managing the lookup count through other optimization strategies.
The Flattening Process: Step by Step
When you're ready to flatten your SPF record, follow a methodical process to minimize risk:
First, document your current record completely. Note every mechanism, understand what each one authorizes, and verify that you know why each service is included.
Second, identify which includes can be safely converted to IP addresses. Contact your email service providers to confirm their sending IP addresses and ask about their change frequency. Many providers document this information publicly or can provide it upon request.
Third, create your new flattened record but don't publish it yet. Use SPF validation tools to verify that your new record produces the same authorization results as your old record for your known sending sources.
Fourth, monitor your email authentication reports (DMARC reports, specifically) to establish a baseline of which IP addresses are currently sending mail from your domain. This helps verify that your flattened record will authorize all legitimate sources.
Fifth, publish your new record with a very low TTL (time to live) value initially, perhaps 300 seconds. This allows you to quickly revert if issues arise. After several days of successful operation, you can increase the TTL to a more standard value like 3600 seconds.
Maintaining Flattened SPF Records
Flattening creates an ongoing maintenance obligation. When email service providers change their sending infrastructure, your record won't automatically update as it would with an include mechanism.
Establish a regular review schedule, perhaps quarterly, to verify that all IP addresses in your SPF record remain current. Some organizations automate this process with scripts that query provider SPF records and alert when changes are detected.
Subscribe to announcements from your email service providers. Most major platforms notify customers before making infrastructure changes that would affect sending IP addresses. Create a distribution list or shared inbox where these notifications can be centrally monitored.
Document your SPF record thoroughly. Future administrators should be able to understand which IP addresses correspond to which services without archaeological research. A simple text file or wiki page listing each IP range with its purpose and the date it was last verified can save significant troubleshooting time.
When Flattening Isn't Enough
Sometimes even aggressive flattening can't bring a complex email infrastructure under the 10-lookup limit. Organizations using numerous email services, particularly those with multiple business units or subsidiaries, may find themselves unable to authorize all legitimate senders within a single SPF record.
At this point, architectural changes become necessary. Options include:
Implementing subdomain delegation where different departments or business units use their own subdomains for email sending. This provides complete isolation and independent SPF records.
Consolidating email services by migrating multiple specialized platforms to a single provider that offers broader functionality. Many modern email platforms can handle transactional mail, marketing campaigns, and support desk communication from a unified infrastructure.
Evaluating whether all email truly needs to come from your primary domain. Some automated systems might be better served by sending from a dedicated subdomain or even a completely separate domain designated for machine-generated mail.
The Role of DMARC in SPF Management
DMARC alignment requirements affect how you should approach SPF optimization. For an email to pass DMARC, it needs to pass either SPF or DKIM, and the passing authentication mechanism must align with the From domain.
This means you have some flexibility. If a particular email sender has reliable DKIM signing, you might not need to include it in your SPF record at all, provided your DMARC policy allows DKIM-only alignment. However, best practice suggests authorizing senders through both mechanisms when possible, providing redundancy if one authentication method fails.
Understanding this relationship helps prioritize which services must be in your SPF record. Services that don't support DKIM signing become higher priorities for SPF inclusion than those with robust DKIM implementation.
Testing Changes Safely
Never deploy SPF changes without thorough testing. Several approaches can help verify your changes before they impact production email:
Use SPF testing tools that simulate the validation process. These tools can show you exactly how receiving servers will process your record and whether it stays within the lookup limit.
If you operate your own mail servers, configure a test domain with your proposed SPF record and send test messages through your various email services. Monitor authentication results to verify everything passes.
Review your DMARC aggregate reports carefully after making changes. These reports show which sources are sending mail from your domain and whether they're passing authentication. An unexpected failure rate after an SPF change indicates an issue that needs immediate attention.
Consider a staged rollout if possible. Some organizations maintain both legacy and production domains, allowing them to test changes in a production-like environment before applying them to their primary domain.
Common Mistakes to Avoid
Several patterns repeatedly cause problems when organizations attempt SPF flattening:
Forgetting to account for all IP addresses in a range. If a provider uses a /24 CIDR block, you need to authorize the entire range, not just the specific IPs you've observed sending mail.
Removing mechanisms you don't recognize without investigation. That cryptic include statement might authorize a critical service that only sends email occasionally.
Failing to update your record when service providers change IP addresses. Set up monitoring and maintain relationships with your providers to stay informed of infrastructure changes.
Publishing an SPF record that's too permissive in an attempt to avoid the lookup limit. Using mechanisms like ip4:0.0.0.0/0or overly broad ranges defeats the purpose of SPF.
Not testing the impact on SPF alignment with DMARC. An IP address might be authorized to send mail, but if it doesn't align with your From domain, it won't help with DMARC compliance.
Advanced Considerations for Large Organizations
Enterprises with complex email infrastructures face unique challenges. Multiple brands, acquired companies, and regional offices all need to send authenticated email, potentially from shared infrastructure.
Some large organizations have adopted centralized email gateways where all outbound mail flows through a limited set of IP addresses regardless of the originating system. This architecture dramatically simplifies SPF management because you only need to authorize your gateway IPs, though it requires significant infrastructure investment.
Another approach involves strict architectural standards for email sending. All authorized services must be registered in a central inventory, and automated systems validate that SPF records match this inventory. This prevents the gradual accumulation of unauthorized senders that often leads to lookup limit violations.
Looking Forward
The SPF lookup limit has been controversial since the specification was published. Some proposals suggest increasing the limit or implementing alternative mechanisms for authorizing email senders. However, as of now, the 10-lookup limit remains in effect, and responsible email administrators must work within this constraint.
The increasing adoption of DKIM and DMARC has made email authentication more robust, providing some flexibility in how organizations approach SPF. As authentication standards evolve, maintaining properly configured SPF records alongside DKIM signing and DMARC policies provides the strongest foundation for email deliverability and security.
Organizations planning their email infrastructure should consider SPF limitations from the beginning. Choosing email service providers that use stable IP ranges, implementing subdomain strategies for different types of mail, and establishing regular SPF auditing procedures all contribute to sustainable, reliable email authentication that won't break as your needs grow.