SPF is essential for verifying authorized email senders, but complex configurations with multiple third-party services can quickly exceed the 10-DNS-lookup limit and trigger an SPF PermError. SPF flattening helps address this issue by replacing nested include mechanisms with authorized IP addresses, reducing DNS lookups and simplifying record management. When implemented and maintained correctly, SPF flattening can improve authentication reliability, support email deliverability, and reduce the risk of legitimate messages failing SPF checks.
Why SPF PermError Happens: DNS Lookup Limits and Complex Sender Setups
The Sender Policy Framework (SPF) is a cornerstone of email authentication, designed to specify which mail servers are permitted to send email on behalf of your domain. However, the complexity of modern email infrastructure—as organizations rely on multiple cloud services, marketing platforms, CRM tools, and third-party senders—has introduced new challenges to maintain a valid SPF record. An SPF flattener can help simplify complex SPF configurations by replacing nested include statements with the corresponding IP addresses, reducing the number of DNS lookups required during SPF evaluation.
A core vulnerability lies in the DNS lookup process. Per RFC 7208, an SPF record is subject to a 10-lookup limit for DNS-based “include” mechanisms, redirect, mx, and a lookups during an authentication check. If the SPF configuration exceeds this DNS lookup limit, the SPF evaluation fails immediately, resulting in an SPF PermError (permanent error).
This SPF PermError frequently arises in organizations utilizing multiple email vendors like Google Workspace (_spf.google.com), Microsoft 365 (spf.protection.outlook.com), Salesforce (_spf.salesforce.com), SendGrid (u538675.wl176.sendgrid.net), Zendesk (mail.zendesk.com), Zoho, Amazon SES, Mandrill (spf.mandrillapp.com), or Sendinblue (spf.sendinblue.com). Each of these services may use their own nested include records, further expanding the number of DNS lookups and inching closer to the 10-lookup threshold. Even a single deeply nested include can trigger an unexpected SPF PermError, especially when infrastructure is updated or vendor IP address automations add new entries in real-time.
With SPF PermError, email authentication checks will fail, and mail servers may outright reject—or silently deliver to spam—legitimate messages, directly undermining email deliverability and causing disruption to business-critical communications.
What SPF Flattening Is and How It Replaces Includes with IP Addresses
SPF flattening addresses the 10-lookup limitation and nested include sprawl by transforming your SPF record’s include mechanisms into direct IP address listings within your DNS TXT record. Instead of storing includes like include:*spf*.protection.outlook.com or include:_spf.*google*.com, the flattening process recursively resolves all nested include records and adds the corresponding authorized IP addresses and IP ranges directly into the SPF configuration.

There are various approaches to SPF flattening:
- Manual Flattening: Security or IT teams manually audit every include in the SPF record, trace all nested includes (including those from new marketing or CRM platforms), extract the underlying IP addresses, and hand-edit the record.
- Automated Flattening (SPF Flattening Tool): Cloud-based services or command-line scripts perform continuous, automated DNS resolution, generating a flattened record by resolving every include automatically. Tools like PowerSPF by PowerDMARC or similar SaaS providers enable dynamic SPF flattening and scheduled auto-reflattens.
- Hosted SPF / Centralized Management: Providers like PowerDMARC offer centralized, hosted SPF records—such as those at domains like kfho42w5d9.powerspf.com—where all updates and flattening are managed automatically.
By using the correct SPF flattening tool, your DNS TXT record is simplified: the includes are replaced with “ip4” and “ip6” entries. This clarity in SPF configuration that results in a flattened record significantly reduces DNS complexity.
How Flattening Reduces DNS Lookups and Prevents SPF Validation Failures
The principal goal of SPF flattening is to minimize the number of DNS queries required during an SPF check, thereby preventing costly SPF failures and the dreaded PermError. Here’s how:
- Elimination of Nested Includes: Each include—especially when nested—counts as a separate DNS lookup. Flattening dissolves include hierarchies, replacing them with explicit IP or CIDR range entries.
- Reduced Real-Time Resolution: During authentication checks, mail servers no longer need to perform multiple DNS lookups to external vendor domains (like _spf.sendinblue.com or spf.mandrillapp.com), as all authorized IPs are already present.
- Compliance with 10-Lookup Limit: With static flattening or automated flattening, the resulting SPF record can be carefully engineered to remain well within the 10-lookup limit, ensuring an SPF PermError is no longer a risk—even as new services are onboarded.
- Improved SPF Pass/Fail Rates: By avoiding DNS timeout or SPF record size limits, mail delivery sees higher authentication pass rates, and DMARC reports show fewer failures related to SPF checks.
In practical terms, mail servers conducting SPF validation reference a simplified DNS TXT record, quickly confirming whether a sending IP is authorized—without risk of timeouts, unexpected SPF macro expansions, or include chain bloat.
Benefits, Risks, and Maintenance Requirements of SPF Flattening
Benefits
- Guaranteed SPF Compliance: Proper SPF flattening guarantees your SPF record respects the DNS lookup limit, thus eliminating the most common cause of SPF PermError.
- Better Email Deliverability: Enhanced authentication checks improve sender reputation and inbox placement, leading to fewer silent SPF failures and better inbox rates, especially with tight DMARC policy enforcement.
- Predictable SPF Pass/Fail Rates: A flattened record provides consistent results regardless of third-party changes, automated monitoring, or nested include complexity.
- Centralized Change Management: With hosted SPF, organizations can consolidate email infrastructure management, easily performing SPF audits, updates, and real-time monitoring.
Risks
- IP Address Changes by Vendors: Many email vendors (e.g., Google, Microsoft, SendGrid) can update their outbound IP ranges without warning. A static flattened record might quickly become inaccurate if IPs are not refreshed, resulting in false SPF failures.
- Maintenance Burden: Manual flattening, while possible, is highly error-prone and unscalable—especially in dynamic cloud environments or with frequent changes in marketing platforms and Customer relationship management (CRM) tools.
- Record Bloat & Size Limits: Flattened records can grow large, possibly exceeding DNS TXT record size limits (RFC 7208 suggests a maximum 255-character string and up to 512 bytes total response size, although DNS providers may vary).
- Potential Oversights in IPs: Without automated monitoring or a capable SPF checker, it’s easy to omit newly authorized IPs or changes by third-party senders.
Maintenance Requirements
- Regular Audits: Periodic SPF audits and updates to accommodate vendor IP address changes are essential for ongoing accuracy.
- Automated Monitoring: Reliance on static flattening should be paired with scheduled, automated SPF checker or flattening tool scans to update DNS as needed.
- Dynamic SPF Solutions: Hosted SPF flattening providers like PowerSPF offer auto-reflattens and centralized SPF updates to streamline maintenance.
Best Practices for Implementing SPF Flattening Safely

Use an Automated SPF Flattening Tool
Manual approaches are not sustainable for large-scale or frequently changing environments. Instead, implement an automated SPF flattening tool—either as part of your own workflow or as a hosted SPF service (e.g., PowerSPF by PowerDMARC). These tools continually resolve and aggregate vendor IPs, ensuring your DNS TXT record is always up-to-date and compliant.
Monitor for IP Address Changes
Email vendors and third-party senders update their infrastructure with little warning. Employ automated monitoring systems that track vendor IP range changes across Google Workspace, Microsoft 365, Salesforce, and others, triggering immediate SPF configuration updates and notifications.
Minimize the Use of Nested Includes
Where possible, avoid nested include mechanisms altogether by directly flattening or using optimized include practices. This reduces the total DNS lookups required and mitigates the risk of hitting the 10-lookup limit.
Use Centralized, Hosted SPF Solutions
Leveraging a centralized, hosted SPF solution from trusted providers allows for scalable, secure, and automatic SPF management—including SPF folding (breaking long records into manageable strings), auto-reflattens, and full compliance with authentication standards.
Regularly Audit and Test with an SPF Checker
Perform routine audits with an SPF checker to detect silent SPF failures, record bloat, and to validate that your SPF pass/fail rates remain optimal. This is especially important in multi-vendor environments or after onboarding new cloud services.
Stay Within DNS Size and Lookup Constraints
Ensure your flattened record respects not just the 10-lookup limit, but also DNS TXT record size limits. Implement SPF folding if the record grows large, and split records sensibly if DNS providers or RFC 7208 limits are approached.
Coordinate with Email Vendors for Seamless Updates
Maintain relationships with email vendors for up-to-date documentation on authorized IPs, optimized include options, and technical support. Some vendors (e.g., Sendinblue, Mailchimp, Mandrill) publish dedicated SPF macro records or special configurations to streamline flattening.
Combine with Robust DMARC and DKIM Policies
SPF flattening is most effective when integrated into a layered security strategy involving DKIM and a strong DMARC policy. This combination maximizes protection against spoofing and improves overall email authentication reliability for your domain.
By following these best practices, organizations can use SPF flattening—whether through static or dynamic SPF methods—to prevent SPF PermError failures, maintain resilient email authentication, and optimize both security and email deliverability across their entire infrastructure.
