{"id":3848,"date":"2025-12-31T20:16:57","date_gmt":"2025-12-31T17:16:57","guid":{"rendered":"https:\/\/www.dchost.com\/blog\/advanced-spf-management-for-multiple-email-providers\/"},"modified":"2026-11-04T23:29:16","modified_gmt":"2026-11-04T20:29:16","slug":"advanced-spf-management-for-multiple-email-providers","status":"publish","type":"post","link":"https:\/\/www.dchost.com\/blog\/en\/advanced-spf-management-for-multiple-email-providers\/","title":{"rendered":"Advanced SPF Management for Multiple Email Providers"},"content":{"rendered":"<div class=\"dchost-blog-content-wrapper\"><p>Once you start using more than one email provider, SPF very quickly stops being a &#8220;set it once and forget it&#8221; record. Marketing platform, CRM, support desk, billing system, your own SMTP on a <a href=\"https:\/\/www.dchost.com\/vps\">VPS<\/a>\u2026 each one wants you to add another <code>include:<\/code>. Before long, an SPF evaluation can exceed the <strong>10 DNS lookup limit<\/strong> and return <code>permerror<\/code>. That means SPF cannot authenticate that message; it does not mean the SPF record is absent.<\/p>\n<p>In this article we\u2019ll look at SPF for domains with multiple providers and long\u2011lived DNS setups. We\u2019ll break down exactly what counts as an SPF lookup, how to count them, and what to do when you\u2019re already over the limit. Then we\u2019ll walk through the uses and limitations of IP consolidation, subdomains, <code>redirect=<\/code>, and SPF flattening for mail sent through shared hosting, VPS and <a href=\"https:\/\/www.dchost.com\/dedicated-server\">dedicated server<\/a>s.<\/p>\n<p>If you already understand the basics of SPF, DKIM and DMARC, this is the next step: <strong>keeping SPF valid and maintainable when your email ecosystem gets complex<\/strong>.<\/p>\n<div id=\"toc_container\" role=\"navigation\" aria-label=\"Table of Contents\" data-nosnippet class=\"toc_transparent no_bullets toc_numbered toc_title_center\"><p class=\"toc_title\">\u0130\u00e7indekiler<\/p><ul class=\"toc_list\"><li><a href=\"#Why_SPF_Hits_a_Wall_with_the_10_DNS_Lookup_Limit\"><span class=\"toc_number toc_depth_1\">1.<\/span> Why SPF Hits a Wall with the 10 DNS Lookup Limit<\/a><\/li><li><a href=\"#Quick_Refresher_How_SPF_and_DNS_Lookups_Actually_Work\"><span class=\"toc_number toc_depth_1\">2.<\/span> Quick Refresher: How SPF and DNS Lookups Actually Work<\/a><ul><li><a href=\"#Mechanisms_and_the_Modifier_that_Count_Toward_the_10_Lookup_Limit\"><span class=\"toc_number toc_depth_2\">2.1.<\/span> Mechanisms and the Modifier that Count Toward the 10 Lookup Limit<\/a><\/li><li><a href=\"#How_to_Manually_Count_SPF_Lookups\"><span class=\"toc_number toc_depth_2\">2.2.<\/span> How to Manually Count SPF Lookups<\/a><\/li><\/ul><\/li><li><a href=\"#Typical_MultiProvider_SPF_Problems\"><span class=\"toc_number toc_depth_1\">3.<\/span> Typical Multi\u2011Provider SPF Problems<\/a><ul><li><a href=\"#Example_Marketing_CRM_Helpdesk_and_InHouse_SMTP\"><span class=\"toc_number toc_depth_2\">3.1.<\/span> Example: Marketing, CRM, Helpdesk and In\u2011House SMTP<\/a><\/li><li><a href=\"#Symptoms_Youll_See_in_the_Real_World\"><span class=\"toc_number toc_depth_2\">3.2.<\/span> Symptoms You\u2019ll See in the Real World<\/a><\/li><\/ul><\/li><li><a href=\"#Strategic_Fixes_Before_You_Touch_DNS\"><span class=\"toc_number toc_depth_1\">4.<\/span> Strategic Fixes Before You Touch DNS<\/a><ul><li><a href=\"#Consolidate_Providers_Where_It_Makes_Sense\"><span class=\"toc_number toc_depth_2\">4.1.<\/span> Consolidate Providers Where It Makes Sense<\/a><\/li><li><a href=\"#Separate_Sending_Domains_for_Different_Use_Cases\"><span class=\"toc_number toc_depth_2\">4.2.<\/span> Separate Sending Domains for Different Use Cases<\/a><\/li><li><a href=\"#Align_SPF_Strategy_with_DMARC_Policy\"><span class=\"toc_number toc_depth_2\">4.3.<\/span> Align SPF Strategy with DMARC Policy<\/a><\/li><\/ul><\/li><li><a href=\"#Technical_Tactics_to_Stay_Under_10_Lookups\"><span class=\"toc_number toc_depth_1\">5.<\/span> Technical Tactics to Stay Under 10 Lookups<\/a><ul><li><a href=\"#1_Prefer_ip4ip6_Over_include_Where_Possible\"><span class=\"toc_number toc_depth_2\">5.1.<\/span> 1. Prefer ip4\/ip6 Over include Where Possible<\/a><\/li><li><a href=\"#2_Use_redirect_to_Split_Responsibilities_Cleanly\"><span class=\"toc_number toc_depth_2\">5.2.<\/span> 2. Use redirect= to Split Responsibilities Cleanly<\/a><\/li><li><a href=\"#3_Move_Edge_UseCases_to_Subdomains\"><span class=\"toc_number toc_depth_2\">5.3.<\/span> 3. Move Edge Use\u2011Cases to Subdomains<\/a><\/li><li><a href=\"#4_Remove_Deprecated_or_Redundant_Mechanisms\"><span class=\"toc_number toc_depth_2\">5.4.<\/span> 4. Remove Deprecated or Redundant Mechanisms<\/a><\/li><\/ul><\/li><li><a href=\"#SPF_Flattening_When_and_How_to_Use_It_Safely\"><span class=\"toc_number toc_depth_1\">6.<\/span> SPF Flattening: When and How to Use It Safely<\/a><ul><li><a href=\"#Manual_Flattening_for_Small_Stable_Setups\"><span class=\"toc_number toc_depth_2\">6.1.<\/span> Manual Flattening for Small, Stable Setups<\/a><\/li><li><a href=\"#Automated_Flattening_with_CICD_and_DNS_APIs\"><span class=\"toc_number toc_depth_2\">6.2.<\/span> Automated Flattening with CI\/CD and DNS APIs<\/a><\/li><li><a href=\"#How_Often_Should_a_Flattened_SPF_Be_Refreshed\"><span class=\"toc_number toc_depth_2\">6.3.<\/span> How Often Should a Flattened SPF Be Refreshed?<\/a><\/li><\/ul><\/li><li><a href=\"#Testing_Monitoring_and_Ongoing_Maintenance\"><span class=\"toc_number toc_depth_1\">7.<\/span> Testing, Monitoring and Ongoing Maintenance<\/a><ul><li><a href=\"#1_Always_Test_New_SPF_Changes\"><span class=\"toc_number toc_depth_2\">7.1.<\/span> 1. Always Test New SPF Changes<\/a><\/li><li><a href=\"#2_Watch_DMARC_Reports_for_permerror_and_Fails\"><span class=\"toc_number toc_depth_2\">7.2.<\/span> 2. Watch DMARC Reports for permerror and Fails<\/a><\/li><li><a href=\"#3_Consider_Forwarding_and_SRSARC_Impacts\"><span class=\"toc_number toc_depth_2\">7.3.<\/span> 3. Consider Forwarding and SRS\/ARC Impacts<\/a><\/li><li><a href=\"#4_ReAudit_Your_SPF_Once_or_Twice_a_Year\"><span class=\"toc_number toc_depth_2\">7.4.<\/span> 4. Re\u2011Audit Your SPF Once or Twice a Year<\/a><\/li><\/ul><\/li><li><a href=\"#Planning_Hosting_and_DNS_for_a_Clean_Scalable_SPF_Strategy\"><span class=\"toc_number toc_depth_1\">8.<\/span> Planning Hosting and DNS for a Clean, Scalable SPF Strategy<\/a><\/li><\/ul><\/div>\n<h2><span id=\"Why_SPF_Hits_a_Wall_with_the_10_DNS_Lookup_Limit\">Why SPF Hits a Wall with the 10 DNS Lookup Limit<\/span><\/h2>\n<p>SPF authorizes sending IP addresses for a domain used in the SMTP envelope MAIL FROM or HELO identity, not the visible From: header. The receiver evaluates the policy\u2019s mechanisms in order; it does not first build a complete list of allowed IPs. To constrain DNS work, the RFC limits evaluation to <strong>10 DNS\u2011causing terms<\/strong> across the policy and any nested evaluation. This is not simply a count of DNS packets sent.<\/p>\n<p>When you\u2019re using multiple external providers, each <code>include:<\/code> you add typically hides several more <code>include:<\/code>s inside it. Two or three vendors can be enough to break SPF, even if the record still &#8220;looks&#8221; short. Once evaluation would exceed 10 DNS\u2011causing terms, the SPF result becomes <code>permerror<\/code> (permanent error). This cannot provide an SPF pass for DMARC, but a successful aligned DKIM signature can still make DMARC pass. Delivery decisions also depend on the receiver\u2019s local policy and other checks.<\/p>\n<p>So advanced SPF management is mostly about one thing: <strong>delivering the intent of your policy while staying under that 10\u2011lookup ceiling<\/strong>.<\/p>\n<h2><span id=\"Quick_Refresher_How_SPF_and_DNS_Lookups_Actually_Work\">Quick Refresher: How SPF and DNS Lookups Actually Work<\/span><\/h2>\n<p>If you need a step\u2011by\u2011step primer on SPF, DKIM and DMARC, we\u2019ve written a dedicated guide: <a href=\"https:\/\/www.dchost.com\/blog\/en\/spf-dkim-dmarc-cpanel-vps-setup\/\">SPF, DKIM and DMARC explained for cPanel and VPS email<\/a>. Here we\u2019ll focus on the pieces that matter for the lookup limit.<\/p>\n<h3><span id=\"Mechanisms_and_the_Modifier_that_Count_Toward_the_10_Lookup_Limit\">Mechanisms and the Modifier that Count Toward the 10 Lookup Limit<\/span><\/h3>\n<p>These SPF mechanisms and the <code>redirect<\/code> modifier count toward the limit when evaluated:<\/p>\n<ul>\n<li><code>include:example.com<\/code> \u2013 fetches the SPF record of another domain.<\/li>\n<li><code>a<\/code> or <code>a:example.com<\/code> \u2013 resolves A\/AAAA records.<\/li>\n<li><code>mx<\/code> or <code>mx:example.com<\/code> \u2013 resolves MX, then A\/AAAA for those hosts.<\/li>\n<li><code>ptr<\/code> \u2013 reverse DNS lookups (and it\u2019s discouraged in modern SPF).<\/li>\n<li><code>exists:example.com<\/code> \u2013 resolves that host.<\/li>\n<li><code>redirect=otherdomain.com<\/code> \u2013 counts as one term when followed; terms evaluated in the target policy share the same limit.<\/li>\n<\/ul>\n<p>These mechanisms <strong>do not<\/strong> trigger DNS lookups:<\/p>\n<ul>\n<li><code>ip4:203.0.113.0\/24<\/code><\/li>\n<li><code>ip6:2001:db8::\/32<\/code><\/li>\n<li><code>all<\/code>, <code>+all<\/code>, <code>~all<\/code>, <code>-all<\/code><\/li>\n<\/ul>\n<h3><span id=\"How_to_Manually_Count_SPF_Lookups\">How to Manually Count SPF Lookups<\/span><\/h3>\n<p>The limit applies to terms reached along an evaluation path, including nested policies, not every term in a fully expanded tree. Trace the paths for your sending IPs and a nonmatching IP to estimate worst\u2011case usage:<\/p>\n<ol>\n<li>Start with your top\u2011level SPF record, e.g. <code>v=spf1 include:mailvendor.com include:crm.example.net ~all<\/code>.<\/li>\n<li>For each <code>include:<\/code>, fetch that domain\u2019s SPF and repeat the process.<\/li>\n<li>Along each path, count every reached <code>include:<\/code>, <code>a<\/code>, <code>mx<\/code>, <code>ptr<\/code> and <code>exists<\/code>, plus <code>redirect=<\/code> when followed, as <strong>one term<\/strong>. Recurse into included or redirected policies using the same counter; stop evaluating a policy when a mechanism matches.<\/li>\n<li>Ignore <code>ip4<\/code>, <code>ip6<\/code> and <code>all<\/code> \u2013 they don\u2019t add lookups.<\/li>\n<li>Ten counted terms are allowed. If the path requires an eleventh, the result is <code>permerror<\/code>; the receiver does not simply ignore the remaining terms.<\/li>\n<\/ol>\n<p>This can be tedious to do by hand, but it\u2019s worth doing at least once for your domain so you get a feel for how &#8220;expensive&#8221; your current providers are in SPF terms.<\/p>\n<h2><span id=\"Typical_MultiProvider_SPF_Problems\">Typical Multi\u2011Provider SPF Problems<\/span><\/h2>\n<p>Consider a hypothetical company with several independent email senders.<\/p>\n<h3><span id=\"Example_Marketing_CRM_Helpdesk_and_InHouse_SMTP\">Example: Marketing, CRM, Helpdesk and In\u2011House SMTP<\/span><\/h3>\n<p>Imagine a mid\u2011size company using:<\/p>\n<ul>\n<li>A hosted email suite for day\u2011to\u2011day mailbox use.<\/li>\n<li>An email marketing platform for newsletters.<\/li>\n<li>A CRM that sends automated follow\u2011ups.<\/li>\n<li>A support\/helpdesk platform for ticket emails.<\/li>\n<li>An on\u2011prem or VPS\u2011based SMTP service for application alerts and transactional mail.<\/li>\n<\/ul>\n<p>Their SPF might look like this. The include targets below are placeholders, not vendor settings to publish:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">example.com. IN TXT &quot;v=spf1 include:mail-suite.example.net include:marketing.example.net include:crm.example.net include:helpdesk.example.net include:vps-smtp.example.net ~all&quot;<\/code><\/pre>\n<p>Each include could pull in further includes and other DNS\u2011causing terms. Five top\u2011level includes alone are within the limit, but a path requiring more than 10 terms across nested policies returns <code>permerror<\/code>. A path that matches earlier may still pass. For a message with SPF <code>permerror<\/code>, DMARC can pass only through successful aligned DKIM.<\/p>\n<h3><span id=\"Symptoms_Youll_See_in_the_Real_World\">Symptoms You\u2019ll See in the Real World<\/span><\/h3>\n<p>When a receiving server\u2019s SPF evaluation exceeds the limit, your outbound logs may not show the authentication result, especially if the receiver accepts the message. Possible signs include:<\/p>\n<ul>\n<li>Deliverability for some providers suddenly drops while others look fine.<\/li>\n<li>DMARC aggregate reports show a lot of <code>spf=permerror<\/code> even for legitimate traffic.<\/li>\n<li>Messages from certain systems (often the &#8220;last&#8221; ones you added) land in spam more often.<\/li>\n<li>Some online testers warn about &#8220;too many DNS lookups&#8221; or &#8220;SPF too complex&#8221;.<\/li>\n<\/ul>\n<p>If you\u2019re working through a broader deliverability checklist, our article <a href=\"https:\/\/www.dchost.com\/blog\/en\/email-deliverability-spf-dkim-dmarc-rdns\/\">Inbox or spam? A friendly, step\u2011by\u2011step guide to SPF, DKIM, DMARC and rDNS<\/a> shows how SPF fits into the bigger picture.<\/p>\n<h2><span id=\"Strategic_Fixes_Before_You_Touch_DNS\">Strategic Fixes Before You Touch DNS<\/span><\/h2>\n<p>Before diving into technical SPF tricks, it\u2019s worth asking some architectural questions. Often the cleanest SPF setup starts with email <strong>strategy<\/strong>, not syntax.<\/p>\n<h3><span id=\"Consolidate_Providers_Where_It_Makes_Sense\">Consolidate Providers Where It Makes Sense<\/span><\/h3>\n<p>A new provider can add SPF complexity, DNS records, and operational overhead. If your stack has grown organically over the years (one tool added per team), consider:<\/p>\n<ul>\n<li>Do you still need every platform that\u2019s allowed to send from your main domain?<\/li>\n<li>Could some campaigns move to an existing provider instead of a new one?<\/li>\n<li>Are there legacy systems that no longer send but are still present in SPF?<\/li>\n<\/ul>\n<p>Pruning unused or low\u2011value senders is often enough to bring SPF back under the limit without any advanced techniques.<\/p>\n<h3><span id=\"Separate_Sending_Domains_for_Different_Use_Cases\">Separate Sending Domains for Different Use Cases<\/span><\/h3>\n<p>One of the most powerful levers you have is the domain itself. Instead of using <code>example.com<\/code> as the envelope MAIL FROM domain for every system, configure separate sending identities on dedicated subdomains where providers support them. Changing only the visible From: address does not change which SPF policy is evaluated. For example:<\/p>\n<ul>\n<li><code>news.example.com<\/code> for newsletters.<\/li>\n<li><code>crm.example.com<\/code> for CRM automation.<\/li>\n<li><code>support.example.com<\/code> for helpdesk replies.<\/li>\n<li><code>billing.example.com<\/code> for invoices and receipts.<\/li>\n<\/ul>\n<p>Each envelope sending domain needs its own SPF policy. The 10\u2011term budget applies per SPF evaluation, including any nested includes or redirects; it does not reset when evaluation enters another domain. Independent subdomain policies can separate the senders that need authorization. For DMARC, each stream still needs successful SPF or DKIM aligned with its visible From: domain; only changing that visible address changes what users see.<\/p>\n<p>We\u2019ve explored this pattern in detail in our article <a href=\"https:\/\/www.dchost.com\/blog\/en\/using-separate-sending-domains-for-transactional-vs-marketing-emails\/\">using separate sending domains for transactional vs marketing emails<\/a>. If you\u2019re struggling with both deliverability and SPF complexity, this is often the best long\u2011term fix.<\/p>\n<h3><span id=\"Align_SPF_Strategy_with_DMARC_Policy\">Align SPF Strategy with DMARC Policy<\/span><\/h3>\n<p>DMARC ties SPF (and DKIM) to the visible From: domain. When DMARC policy and SPF architecture are designed together, you can:<\/p>\n<ul>\n<li>Keep the main domain\u2019s SPF focused on systems that use it as their envelope MAIL FROM domain.<\/li>\n<li>For separate sending identities, configure the envelope domain and visible From: domain deliberately: relaxed DMARC alignment compares organizational domains, while strict alignment requires an exact match. A subdomain SPF record alone does not establish alignment.<\/li>\n<li>Use DMARC aggregate (RUA) reports to see which services <em>actually<\/em> send.<\/li>\n<\/ul>\n<p>That last point is important: DMARC reports reveal forgotten systems that still send email. Cleaning those up reduces both SPF complexity and surprise reputation issues later.<\/p>\n<h2><span id=\"Technical_Tactics_to_Stay_Under_10_Lookups\">Technical Tactics to Stay Under 10 Lookups<\/span><\/h2>\n<p>Once you\u2019ve decided which systems should legitimately send for each domain or subdomain, it\u2019s time to design SPF syntax that stays within the limit.<\/p>\n<h3><span id=\"1_Prefer_ip4ip6_Over_include_Where_Possible\">1. Prefer ip4\/ip6 Over include Where Possible<\/span><\/h3>\n<p>Many providers\u2019 SPF documentation tells you to just add their <code>include:<\/code> and be done. That\u2019s convenient for them, but not always optimal for you. If a provider documents a complete, stable set of outbound IP ranges and you can maintain updates, replacing its <code>include:<\/code> with explicit addresses may be practical:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">v=spf1 include:spf.vendor.com ~all<\/code><\/pre>\n<p>might become the following illustrative record. The vendor name above is a placeholder, not a verified policy; the documentation addresses below must be replaced with authorized outbound ranges before use:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">v=spf1 ip4:203.0.113.0\/24 ip4:198.51.100.10 ip6:2001:db8:1234::\/48 ~all<\/code><\/pre>\n<p>Advantages:<\/p>\n<ul>\n<li>No DNS lookups for those entries.<\/li>\n<li>Full control over exactly which IPs are allowed.<\/li>\n<\/ul>\n<p>Trade\u2011offs:<\/p>\n<ul>\n<li>You must monitor the provider\u2019s IP range changes (status pages, documentation, mailing lists).<\/li>\n<li>More manual work if they change infrastructure frequently.<\/li>\n<\/ul>\n<p>This approach works best for systems you control (e.g. your own VPS or dedicated server) and for providers with clearly documented, rarely changing ranges.<\/p>\n<h3><span id=\"2_Use_redirect_to_Split_Responsibilities_Cleanly\">2. Use redirect= to Split Responsibilities Cleanly<\/span><\/h3>\n<p>A record containing only <code>v=spf1<\/code> and <code>redirect=<\/code> delegates evaluation to the target domain\u2019s SPF policy, as in this example:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">example.com. IN TXT &quot;v=spf1 redirect=_spf.example.com&quot;\n\n_spf.example.com. IN TXT &quot;v=spf1 ip4:203.0.113.0\/24 ip4:198.51.100.10 ~all&quot;<\/code><\/pre>\n<p>Key points:<\/p>\n<ul>\n<li>An evaluated <code>redirect=<\/code> counts toward the same 10-term DNS lookup limit as <code>include:<\/code>; DNS-causing terms evaluated in the target policy also count. It does not reset the budget.<\/li>\n<li>In this example, the referring record contains no mechanisms; the target holds the authorized IP ranges and the final <code>~all<\/code> policy.<\/li>\n<li>This pattern is great for centralizing complex logic under a helper domain (e.g. <code>_spf.example.com<\/code>) while leaving <code>example.com<\/code> with a short, simple record.<\/li>\n<\/ul>\n<p>Centralization simplifies maintenance, not evaluation: the helper policy must still fit within the shared lookup budget.<\/p>\n<h3><span id=\"3_Move_Edge_UseCases_to_Subdomains\">3. Move Edge Use\u2011Cases to Subdomains<\/span><\/h3>\n<p>If your main domain is already near the limit, offload non\u2011critical or noisy senders to subdomains with their own SPF records. For instance, configure a monitoring system\u2019s envelope MAIL FROM as <code>alerts&#64;infra.example.com<\/code> instead of <code>alerts&#64;example.com<\/code>, then publish SPF at that subdomain. Changing only the visible From: address is not enough. The following record uses an illustrative IP address that must be replaced with the actual outbound IP:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">infra.example.com. IN TXT &quot;v=spf1 ip4:198.51.100.20 ~all&quot;<\/code><\/pre>\n<p>Advantages:<\/p>\n<ul>\n<li>Keeps the primary domain\u2019s SPF focused on its own senders.<\/li>\n<li>Gives mail evaluated against the subdomain\u2019s SPF a separate 10-term budget. Including that policy from the parent does not create extra capacity within the parent\u2019s evaluation.<\/li>\n<li>Helps distinguish operational email from customer\u2011facing traffic in DMARC reports when the sending identities are distinct.<\/li>\n<\/ul>\n<p>This approach pairs nicely with a robust hosting setup \u2013 for example, running monitoring and automation tools on a VPS with their own sending identity \u2013 instead of trying to squeeze everything into one busy SPF record.<\/p>\n<h3><span id=\"4_Remove_Deprecated_or_Redundant_Mechanisms\">4. Remove Deprecated or Redundant Mechanisms<\/span><\/h3>\n<p>As SPF evolved, some mechanisms fell out of favor, especially <code>ptr<\/code>. If your record still contains <code>ptr<\/code> or overly broad <code>a<\/code>\/<code>mx<\/code> mechanisms, you may be wasting lookups:<\/p>\n<ul>\n<li>Remove <code>mx<\/code> if inbound servers do not send outbound mail; authorize the actual outbound systems instead.<\/li>\n<li>Replace any legitimate authorization supplied by <code>ptr<\/code> before removing it.<\/li>\n<li>Review the addresses and CIDR ranges authorized by <code>a<\/code> mechanisms, and narrow or remove unintended authorization.<\/li>\n<\/ul>\n<p>Each removed lookup is room you can spend where it matters more.<\/p>\n<h2><span id=\"SPF_Flattening_When_and_How_to_Use_It_Safely\">SPF Flattening: When and How to Use It Safely<\/span><\/h2>\n<p>Sometimes you really do need several providers, and their SPF policies are &#8220;heavy&#8221;: lots of nested includes, geo\u2011sharded IPs, and so on. That\u2019s when SPF flattening becomes useful.<\/p>\n<p><strong>SPF flattening<\/strong> replaces suitable lookup\u2011based authorization with precomputed <code>ip4<\/code>\/<code>ip6<\/code> ranges, optionally retaining some necessary includes. It is not simply collecting every address found in DNS: the replacement must preserve which senders the original policy authorizes. Policies whose authorization depends on request-specific data may not have an equivalent static IP list.<\/p>\n<p>We\u2019ve published a dedicated, very hands\u2011on guide to automated flattening: <a href=\"https:\/\/www.dchost.com\/blog\/en\/beat-the-10-lookup-wall-automated-spf-flattening-with-ci-cd-or-workers-without-the-drama\/\">how to beat the 10 lookup wall with automated SPF flattening<\/a>. Below is the conceptual version for planning.<\/p>\n<h3><span id=\"Manual_Flattening_for_Small_Stable_Setups\">Manual Flattening for Small, Stable Setups<\/span><\/h3>\n<p>For a simple stack with documented, stable outbound ranges, manual flattening can work if you monitor upstream changes and update the record when needed:<\/p>\n<ol>\n<li>Take your current SPF and list all <code>include:<\/code>, <code>mx<\/code>, <code>a<\/code> and other lookup\u2011based mechanisms.<\/li>\n<li>Use <code>dig<\/code> or <code>nslookup<\/code> to inspect DNS, and an SPF-aware tool to evaluate nested policies. Do not treat every returned address as authorized; preserve the original policy\u2019s outcomes and leave unsupported or request-dependent mechanisms unflattened.<\/li>\n<li>Compose a new SPF record using only <code>ip4<\/code> and <code>ip6<\/code> (and maybe a small number of truly necessary includes), for example, using documentation addresses that must be replaced with your authorized outbound ranges:<br \/>\n  <code>v=spf1 ip4:203.0.113.0\/24 ip4:198.51.100.10 ip6:2001:db8:1234::\/48 ~all<\/code><\/li>\n<li>Validate syntax, DNS size and lookup limits, and compare expected results for authorized and unauthorized senders before publishing. Replace the existing SPF TXT policy rather than adding a second one, then test delivery and monitor results.<\/li>\n<\/ol>\n<p>Manual flattening is practical only while the replacement remains equivalent to the intended policy. Stale data can omit new legitimate senders or continue authorizing retired IPs. For infrastructure you control, such as a fixed outbound gateway, tie SPF updates to server and IP allocation changes.<\/p>\n<h3><span id=\"Automated_Flattening_with_CICD_and_DNS_APIs\">Automated Flattening with CI\/CD and DNS APIs<\/span><\/h3>\n<p>For more dynamic or larger setups, automation is your friend. The pattern we like looks like this:<\/p>\n<ul>\n<li>Keep a &#8220;source of truth&#8221; SPF template in version control (e.g. Git) that still uses includes, with placeholder provider domains in this illustration: <code>v=spf1 include:spf.marketing-platform.com include:spf.crmvendor.com ~all<\/code>.<\/li>\n<li>Have a scheduled job (CI pipeline, cron job on a management VPS, etc.) that:<\/li>\n<\/ul>\n<ol>\n<li>Evaluates the supported parts of the template with an SPF-aware tool and derives the authorized ranges.<\/li>\n<li>Builds a candidate record, preserving any mechanisms that cannot safely be flattened.<\/li>\n<li>Validates syntax, DNS size, lookup limits and expected authorization results; on resolution or validation failure, retains the last known good record and alerts an operator.<\/li>\n<li>Replaces the existing SPF TXT policy via the DNS API only after validation, using credentials scoped to the required DNS changes.<\/li>\n<li>Stores the generated SPF and its inputs for auditing and rollback, and verifies the published result.<\/li>\n<\/ol>\n<p>This can reduce lookup use and track upstream IP changes, provided resolution, validation and DNS publication succeed. Monitor job failures and stale output rather than assuming the automation guarantees a current policy. If you\u2019re already using automation tools for your infrastructure \u2013 for example, provisioning VPSs with Ansible or Terraform as in our guide <a href=\"https:\/\/www.dchost.com\/blog\/en\/terraform-ansible-vps-automation\/\">automating VPS setup with Terraform and Ansible<\/a> \u2013 adding SPF flattening into that flow is a natural step.<\/p>\n<h3><span id=\"How_Often_Should_a_Flattened_SPF_Be_Refreshed\">How Often Should a Flattened SPF Be Refreshed?<\/span><\/h3>\n<p>Choose a refresh process based on upstream change practices and the consequences of stale authorization, not a universal daily or weekly interval:<\/p>\n<ul>\n<li><strong>External providers<\/strong>: follow documented change notices and DNS TTLs when planning refreshes. A fixed daily or weekly job can still miss a change before new IPs begin sending.<\/li>\n<li><strong>Providers without a dependable update process<\/strong>: retain their supported includes where possible, or use a separate envelope sending domain rather than relying on a stale snapshot.<\/li>\n<li><strong>Your own infrastructure<\/strong> (VPS\/dedicated servers with static IPs): authorize new outbound IPs before sending from them and remove retired IPs when they no longer send.<\/li>\n<\/ul>\n<p>Automated flattening makes this schedule easy to maintain. You can even let different parts of the SPF come from different sources (some static IP ranges, some dynamic from flattening) as long as the published record preserves the intended authorization, stays current, fits DNS size limits and remains within the 10\u2011lookup budget.<\/p>\n<h2><span id=\"Testing_Monitoring_and_Ongoing_Maintenance\">Testing, Monitoring and Ongoing Maintenance<\/span><\/h2>\n<p>SPF is not a &#8220;set and forget&#8221; record once you\u2019re using multiple providers. A few lightweight habits keep it healthy:<\/p>\n<h3><span id=\"1_Always_Test_New_SPF_Changes\">1. Always Test New SPF Changes<\/span><\/h3>\n<p>Before and after changing SPF:<\/p>\n<ul>\n<li>Use command\u2011line tools (<code>dig<\/code>, <code>nslookup<\/code>) to inspect the TXT policy at authoritative servers and selected recursive resolvers. Sampled answers do not prove every cache has refreshed.<\/li>\n<li>Send test emails from each legitimate sending path to major mailbox providers (Gmail, Outlook.com, etc.) and inspect receiver-added authentication headers for SPF pass on the intended MAIL FROM domain and for DMARC alignment.<\/li>\n<li>Use a reputable SPF syntax\/lookup checker to confirm you\u2019re under the 10\u2011lookup limit and there are no hidden includes.<\/li>\n<\/ul>\n<p>If you run your own inbound mail server on a VPS or dedicated server with SPF checking and logging enabled, its logs can show SPF results for messages it receives. To check your outbound SPF, inspect results at the receiving server.<\/p>\n<h3><span id=\"2_Watch_DMARC_Reports_for_permerror_and_Fails\">2. Watch DMARC Reports for permerror and Fails<\/span><\/h3>\n<p>DMARC aggregate (RUA) reports are an excellent early\u2011warning system. If you already have DMARC set up to send reports, look for:<\/p>\n<ul>\n<li>Rows whose raw SPF authentication results show <code>spf=permerror<\/code> for legitimate IPs.<\/li>\n<li>New senders that appear from IPs or providers you didn\u2019t expect.<\/li>\n<li>Differences between SPF and DKIM alignment (sometimes you can rely on DKIM and simplify SPF).<\/li>\n<\/ul>\n<p>For a deeper dive into DMARC analysis and BIMI, see our article <a href=\"https:\/\/www.dchost.com\/blog\/en\/beyond-pnone-the-friendly-playbook-for-advanced-dmarc-rua-ruf-analysis-and-bimi-that-actually-works\/\">beyond p=none: advanced DMARC, RUA\/RUF analysis and BIMI<\/a>.<\/p>\n<h3><span id=\"3_Consider_Forwarding_and_SRSARC_Impacts\">3. Consider Forwarding and SRS\/ARC Impacts<\/span><\/h3>\n<p>SPF checks the connecting IP against the envelope sender\u2019s policy, so traditional email forwarding often breaks SPF. DMARC can still pass if an aligned DKIM signature survives forwarding. If you rely heavily on forwarding rules, you\u2019ll want to:<\/p>\n<ul>\n<li>Use forwarders that implement SRS (Sender Rewriting Scheme) to rewrite the envelope sender so SPF can pass for the forwarder\u2019s domain. This does not by itself restore SPF alignment with the original visible From domain.<\/li>\n<li>Leverage ARC (Authenticated Received Chain) where supported to carry authentication results through forwarding chains. Receivers must decide whether to trust those assessments; ARC does not automatically override DMARC failure.<\/li>\n<\/ul>\n<p>We\u2019ve covered this in detail in <a href=\"https:\/\/www.dchost.com\/blog\/en\/forwarding-broke-your-spf-dmarc-heres-how-srs-and-arc-save-the-day-without-tears\/\">why forwarding breaks SPF\/DMARC and how SRS and ARC help<\/a>. While forwarding is not directly part of the 10\u2011lookup limit problem, it strongly influences how your SPF strategy behaves in the wild.<\/p>\n<h3><span id=\"4_ReAudit_Your_SPF_Once_or_Twice_a_Year\">4. Re\u2011Audit Your SPF Once or Twice a Year<\/span><\/h3>\n<p>Businesses change marketing platforms, CRM tools and support systems all the time. Put a recurring reminder on your calendar to:<\/p>\n<ul>\n<li>List all systems that <em>actually<\/em> send email for each domain.<\/li>\n<li>Compare with what your SPF and DMARC reports say.<\/li>\n<li>Remove any systems you no longer use.<\/li>\n<li>Recalculate lookup counts and adjust includes or flattening schedules as needed.<\/li>\n<\/ul>\n<p>This is also a great moment to align with broader hosting and infrastructure reviews \u2013 for example, when you\u2019re planning upgrades to your VPS or consolidating services across data centers.<\/p>\n<h2><span id=\"Planning_Hosting_and_DNS_for_a_Clean_Scalable_SPF_Strategy\">Planning Hosting and DNS for a Clean, Scalable SPF Strategy<\/span><\/h2>\n<p>Good SPF design lives at the intersection of DNS, email providers and the servers that actually send your mail.<\/p>\n<p>Consider these design options when planning around the 10\u2011lookup limit:<\/p>\n<ul>\n<li><strong>DNS and domain planning:<\/strong> Designing a domain\/subdomain layout that separates marketing, transactional and support mail, with clear SPF and DMARC policies for each.<\/li>\n<li><strong>Hosting mail gateways on VPS\/dedicated servers:<\/strong> For a central SMTP relay or self\u2011hosted mail stack, size servers for the expected volume and identify their outbound IPs. Stable outbound addresses can keep SPF simple (often just a few <code>ip4<\/code>\/<code>ip6<\/code> entries).<\/li>\n<li><strong>SPF flattening automation:<\/strong> Integrating SPF generation into your existing CI\/CD or management scripts, using DNS APIs and the same automation mindset you might already apply to your web stack.<\/li>\n<li><strong>End\u2011to\u2011end deliverability tuning:<\/strong> Aligning SPF work with DKIM, DMARC, rDNS and IP reputation. Our guides such as <a href=\"https:\/\/www.dchost.com\/blog\/en\/dedicated-ip-warmup-for-transactional-email\/\">dedicated IP warmup and email reputation management<\/a> fit naturally into this process.<\/li>\n<\/ul>\n<p>If you\u2019re planning a new email architecture, migrating providers, or simply suspect your SPF is &#8220;too complicated&#8221;, it\u2019s a good time to step back and design it properly. With the right domain strategy, a sensible choice of providers, and a bit of automation where it pays off, <strong>the 10 DNS lookup limit stops being a hard wall and becomes just another design constraint you know how to work with<\/strong>.<\/p>\n<p>Before choosing hosting for a self\u2011hosted mail stack, verify the plan\u2019s outbound SMTP policy, availability of stable sending IPs, and ability to configure matching forward and reverse DNS.<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Keep multi-provider SPF maintainable within the 10-term lookup limit. Learn how evaluation paths, envelope subdomains, redirect and carefully maintained flattening affect your policy.<\/p>\n","protected":false},"author":1,"featured_media":13193,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[184],"tags":[],"class_list":["post-3848","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/3848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/comments?post=3848"}],"version-history":[{"count":6,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/3848\/revisions"}],"predecessor-version":[{"id":13195,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/3848\/revisions\/13195"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/media\/13193"}],"wp:attachment":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/media?parent=3848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/categories?post=3848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/tags?post=3848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}