← All posts

Multiple SPF Records: Prevent PermError

Multiple SPF records cause PermError & break email delivery. Merge records, stay under the 10-lookup limit, & verify your fix to ensure reliable email.

Multiple SPF Records: Prevent PermError

You add a new sender, publish what looks like the right TXT record, and move on. Then replies stop arriving, transactional mail drifts into spam, and the team starts blaming the new provider.

In most cases, the problem isn't the provider. It's multiple spf records.

This mistake looks harmless because DNS lets you publish more than one TXT record. SPF does not. If your domain already sends through a support platform, a marketing tool, a corporate mailbox provider, and an agent workflow, adding one more standalone SPF record can break authentication for all of them. For developers building automated systems, that's a bad failure mode because email doesn't always fail loudly. Sometimes it just gets filtered, delayed, or discarded.

The One-Record Rule Why Multiple SPF Records Guarantee Failure

You don't get flexibility with SPF. You get one record.

RFC 7208 is explicit. A domain must not publish multiple SPF records that could both be selected during evaluation. The standard says that “a domain name MUST NOT have multiple records that would cause an authorization check to select more than one record.” When a receiving server finds multiple SPF records, it returns PermError, which breaks SPF authentication entirely, as explained in Mailtrap’s breakdown of multiple SPF records.

A stressed man looking at a tangled mess of email tools and a failed delivery icon.

The practical effect is simple. If your DNS has two separate entries that both start with v=spf1, the receiving server doesn't merge them for you. It doesn't pick the one that seems newer. It doesn't try to be helpful.

It stops.

Why receivers reject the setup

Think of SPF like a guest list at the door. The receiver asks your domain one question: which senders are authorized? If your domain hands back two different lists, the receiver can't know which one is authoritative. That ambiguity is the failure.

Practical rule: One domain gets one SPF policy. If you need to authorize more senders, add them to the same record.

This is why a domain can pass internal spot checks and still fail in production. One team adds a record for the company mailbox provider. Another adds a record for a campaign platform. A third adds one for a new workflow. DNS accepts all of them, but SPF evaluation doesn't.

What usually causes duplicate records

Multiple spf records usually show up during ordinary operational changes:

  • New service onboarding: Someone follows a vendor setup guide and publishes a fresh v=spf1 TXT record instead of editing the existing one.
  • Migrations: Old and new senders run at the same time, and both teams publish their own policy.
  • Split ownership: Marketing, IT, and product each manage different mail systems without a shared DNS change process.
  • Stale records: A deprecated service is removed from production but its SPF entry stays behind.

PowerDMARC identified multiple SPF records as a common configuration mistake in the Mailtrap summary above. That tracks with what engineers see in the field. The issue isn't that SPF is obscure. It's that DNS editing is decentralized and SPF gives you almost no room for sloppy coordination.

If your domain has duplicate SPF records, don't debate which one is “primary.” Consolidate them into one valid policy.

How Mail Servers Count Lookups and Why Your Merged Record Can Still Fail

Getting down to one SPF record is necessary. It isn't sufficient.

A lot of teams fix multiple spf records correctly, publish one merged entry, and still break authentication because the final record exceeds SPF's lookup budget. RFC 7208 limits SPF evaluation to 10 DNS lookups, and certain mechanisms consume that budget as the receiver processes the record. AutoSPF notes that each include, a, or mx can trigger recursive queries, and in an analysis of over 1,000 domains, 35% of multi-record merges failed after consolidation because of lookup overflow, according to AutoSPF’s merge analysis.

A diagram illustrating the five-step process of evaluating SPF record lookups and the 10-lookup limit.

What counts as a lookup

SPF isn't counting characters here. It's counting DNS work.

These mechanisms matter because they can trigger additional queries during evaluation:

Mechanism Lookup impact
include Consumes lookup budget and can pull in more nested lookups
a Triggers DNS resolution
mx Triggers DNS resolution
exists Triggers DNS resolution
ptr Triggers DNS resolution and is best avoided

By contrast, ip4 and ip6 literals don't consume DNS lookups in the same way. That's why direct IP authorization is often safer when you need to control lookup growth.

Why merged records fail unexpectedly

The problem isn't only what you can see in your own SPF string. The receiver also evaluates whatever each include expands into.

A short record can still be heavy:

  1. Your domain includes one mailbox provider.
  2. It includes a second sender for outbound notifications.
  3. It includes a third system for support or automation.
  4. One of those included policies references more nested mechanisms.
  5. The total crosses the limit and SPF returns PermError.

A single merged SPF record can be perfectly syntactic and still fail operationally because the receiver has to chase too many DNS references.

That matters most in modern stacks where one domain sends through several services. Corporate mail, support tooling, marketing, and agent-driven workflows often share the same root domain. Each new integration looks small on its own. The lookup chain says otherwise.

How to think about lookup budget

Treat SPF like a constrained runtime environment.

  • Spend budget on real senders: Remove services that no longer send mail for the domain.
  • Prefer direct authorization where possible: Static IP entries avoid recursive SPF expansion.
  • Inspect vendor includes before adding them: Some are lightweight. Some pull in multiple nested records.
  • Count before publishing: If you're close to the limit, merging alone won't save you.

The hidden trap in multiple spf records work is this: the first problem is duplication, but the second problem is complexity. Engineers usually catch the first because it's visible in DNS. The second only shows up when the receiver evaluates the policy.

The Right Way to Merge Multiple SPF Records

The correct fix is not “delete one record and hope.” The fix is to gather every authorized sender and express them in a single SPF policy.

That means one v=spf1 at the beginning, one all mechanism at the end, and every authorized source in between. You are not combining TXT records as separate objects. You are rebuilding one coherent authorization list.

Start with an inventory, not DNS edits

Before touching the record, list every system that sends mail from the domain. Most broken merges happen because teams work from old assumptions.

Use a short working checklist:

  • Corporate mailbox platform: The system people use for ordinary outbound mail
  • Transactional sender: Password resets, receipts, alerts, and workflow mail
  • Support platform: Shared inbox or ticketing system that replies from the main domain
  • Marketing or outreach tooling: Newsletters, campaigns, lifecycle messages
  • Internal apps and automation: Anything that sends directly from your infrastructure

If you're doing this across teams, a configuration management tool becomes especially valuable. Not because SPF is special, but because DNS changes fail when ownership is informal.

What a clean merge looks like

A common pattern is one record for a workplace mailbox provider and another for a transactional sender. The wrong approach is to publish both as separate SPF TXT records.

The right approach is to take the authorization mechanisms from both and place them into one record under a single SPF declaration.

Example pattern:

State Pattern
Before One SPF record for mailbox sending, one separate SPF record for application sending
After One SPF record containing both providers’ authorization mechanisms, ending with one all qualifier

The practical sequence is straightforward:

  1. Identify every existing v=spf1 TXT record for the domain.
  2. Copy the mechanisms from each valid sender policy.
  3. Remove duplicate mechanisms.
  4. Place them under a single v=spf1.
  5. End the record with one final all mechanism.

Common SPF include values for popular services

Teams usually lose time at this point. They know they need to merge but not which service-specific value belongs in the single record.

Service SPF include Value
Google Workspace include:_spf.google.com
SendGrid include:sendgrid.net

Those values belong inside one SPF record, not as separate records.

Keep the policy readable. If you can't explain why a sender is present, it probably shouldn't be in the record.

What does not work

Three patterns cause repeated breakage:

  • Publishing a second SPF TXT record for the new service. This recreates the original error.
  • Copying two complete SPF strings into one line. A valid merged record only has one v=spf1 declaration.
  • Keeping retired senders “just in case.” Old entries raise lookup pressure and make troubleshooting harder.

The operational habit that works is simple: whenever a new sender is added, update the existing SPF record. Don't create another one.

Integrating Robotomail with an Existing SPF Record

When you add a new email system to a domain that already sends mail, the safest assumption is that an SPF record already exists. That's where teams make the mistake. They follow setup instructions, publish a fresh SPF TXT record, and accidentally create multiple spf records.

The right move is to treat the new sender as one more authorized source inside the existing policy.

A friendly robot assembling puzzle pieces containing SPF record segments for email domain configuration and security.

Where to get the authentication details

If you're working with a custom domain, start in the provider's authentication setup and confirm what DNS changes are required. For Robotomail specifically, the relevant setup flow is documented in Robotomail authentication docs.

The important discipline is this: if your domain already has an SPF record, don't add a second SPF TXT record for Robotomail. Add the required authorization mechanism to the existing SPF policy after verifying the full set of current senders.

How to update the DNS record safely

Use your DNS provider's control panel and inspect all TXT records for the domain before editing anything. Look specifically for entries beginning with v=spf1.

Then work through this order:

  1. Confirm which current SPF record is live and intentional.
  2. Identify whether existing senders still belong there.
  3. Add the new sender authorization into that same record.
  4. Save the change and re-check the final policy for duplication and lookup growth.

Domain-level authentication is shared infrastructure. The new sender doesn't live in isolation; it joins everything already using the domain.

A safer rollout pattern

For developer teams, the cleanest rollout isn't “make the DNS change and test later.” It's “inspect, merge, validate, then send.” That prevents a new integration from degrading unrelated mail streams.

A good operational note for AI-agent workflows is to isolate who owns domain changes. Product engineers may control the integration, but infrastructure or platform teams should still review the final SPF policy if multiple services send from the same domain.

If one domain supports human mailboxes, transactional notifications, and autonomous workflows, SPF changes are production changes, not setup chores.

The DNS interface varies by provider, but the process does not. You edit the existing SPF TXT record when one exists. You only create a new SPF record if the domain has none.

Advanced SPF Troubleshooting When Merging Is Not Enough

Sometimes you do everything right. One SPF record. No duplicate declarations. Clean syntax. The record still fails because the merged policy crosses the DNS lookup limit.

That's the point where basic advice stops being useful.

Flattening reduces lookups but adds maintenance risk

The usual workaround is SPF flattening. Instead of referencing another domain with include, flattening replaces that reference with underlying IP authorizations so the receiver performs fewer DNS lookups during SPF evaluation.

That can help, but it comes with a nasty trade-off. Duocircle notes that flattening tools require ongoing updates when provider IPs change, and in dynamic cloud environments this can create “huge losses” when records become invalid, as described in Duocircle’s discussion of multiple SPF records and lookup limits.

For static environments, flattening can be workable. For cloud-heavy systems, it can become a silent failure generator.

Where flattening backfires

Flattening is weakest where infrastructure changes frequently:

  • Cloud-based senders: Providers rotate infrastructure and your flattened policy can become stale.
  • Autonomous systems: No human notices the issue until delivery degrades.
  • Multi-vendor stacks: One stale authorization among several is hard to isolate quickly.
  • Inherited DNS ownership: Teams forget who is responsible for refreshing flattened records.

This is why “just flatten it” is incomplete advice. Lower lookup count is good. Higher maintenance exposure is not.

A more practical decision rule

Use flattening only when you can also guarantee disciplined upkeep. If you can't, reduce SPF complexity first.

That usually means:

Option Best use
Remove unused senders First move when the policy has accumulated stale services
Replace nested includes where possible Good when you control stable infrastructure
Flatten selectively Useful when a specific include chain is the lookup problem
Move some traffic to subdomains Helpful when one root domain is carrying too many unrelated senders

If you're designing email infrastructure for automated workflows, it's worth reviewing broader DNS guidance for email systems before you start compressing SPF aggressively. SPF optimization works better when the surrounding domain strategy is clean.

The hard lesson is that advanced SPF fixes are never free. You either pay in lookup count or you pay in maintenance burden.

How to Test and Verify Your Final SPF Record

After you update DNS, don't trust the change because it saved successfully. Trust it after validation.

A broken SPF record doesn't just create a technical warning. Valimail notes that SPF PermError can lead to spam placement, outright rejection, lost communications, and sender trust damage that can take months to recover, according to Valimail’s analysis of duplicate SPF records and reputation impact.

A happy person pointing at a computer screen showing a successful SPF record verification pass status.

What to check first

You want answers to four questions:

  • Is there exactly one SPF record? More than one means you still have the original problem.
  • Is the syntax valid? A single typo can invalidate the whole policy.
  • Is the lookup count safe? Merged records can still fail if evaluation expands too far.
  • Does the result align with actual senders? A technically valid record can still omit a production sender.

Useful validation methods

Use both a web-based validator and a direct DNS query. The combination catches different classes of mistakes.

A practical sequence looks like this:

  1. Query the domain's TXT records directly with your preferred command-line tool.
  2. Confirm there's only one entry beginning with v=spf1.
  3. Run the record through an SPF validator such as MXToolbox or DMARCLY.
  4. Review any recursive includes and total lookup count.
  5. Send controlled test mail from each sender that uses the domain.

Validation is not complete until every real sender path has been exercised.

What success and failure look like

A healthy result is boring. One SPF record appears. The validator parses it cleanly. The lookup count stays within limits. Test messages authenticate as expected.

A bad result usually falls into one of these buckets:

  • Multiple v=spf1 records still exist
  • The merged record has syntax errors
  • Lookup expansion crosses the allowed threshold
  • A sender was forgotten during consolidation

If mail starts failing after “successful” SPF cleanup, re-check sender inventory before blaming DNS propagation. In practice, incomplete inventory causes as many problems as bad syntax.

Conclusion Building Resilient Email for Autonomous Agents

SPF is unforgiving in exactly the way production infrastructure tends to be unforgiving. Small mistakes at the configuration layer create large failures at the application layer.

The durable rule set is straightforward. One domain gets one SPF record. Every legitimate sender must be represented inside that one policy. Every change has to be validated for both correctness and lookup cost.

The operating model that holds up

Teams that avoid repeated SPF failures usually follow the same pattern:

  • Centralize ownership: One group approves domain-level mail changes
  • Update, don't append: New senders go into the existing SPF policy
  • Audit regularly: Retired services shouldn't keep consuming policy space
  • Test after every change: DNS success is not deliverability success

This matters more when you're building autonomous systems. Human-operated email can sometimes survive partial breakage because people notice and escalate. Agents don't. They keep sending, keep waiting, and keep assuming the channel works unless your infrastructure proves otherwise.

Why this is bigger than SPF syntax

For AI workflows, email isn't just outbound messaging. It's state transfer, task completion, exception handling, and conversation continuity. If SPF breaks, your system doesn't just lose deliverability. It loses reliability.

That's why DNS hygiene belongs in the same bucket as queue durability, webhook signing, and retry logic. It's not glamorous, but it decides whether the system behaves predictably in practice.

If you're tightening the broader foundation around sending domains, this guide on email security best practices is a useful companion to SPF cleanup.

Build email like shared infrastructure, not like a one-time integration. That's how autonomous systems keep working when the easy path would have failed unnoticed.

Frequently Asked Questions About SPF Records

What's the difference between include and redirect

include says, in effect, “also evaluate that policy as part of mine.” It's the normal choice when multiple services are allowed to send for the same domain.

redirect is different. It hands evaluation to another SPF policy instead of building a combined one. In practice, that makes redirect more appropriate when one domain should defer SPF policy to another domain entirely.

For most multi-sender production setups, include is the better fit because you're composing authorization from several sources. If you're trying to fix multiple spf records, redirect usually isn't the first tool to reach for.

Should I use ~all or -all

Both define what happens to mail that doesn't match authorized senders.

  • ~all is SoftFail. It signals that unauthorized senders are suspicious.
  • -all is Fail. It is stricter.
  • ?all is Neutral. It doesn't give receivers much guidance.

A practical recommendation is to use the qualifier that matches your operational confidence. If you've fully inventoried senders and tested the final policy, stricter enforcement is reasonable. If you're still cleaning up inherited infrastructure, a softer ending may reduce the chance of blocking legitimate mail while you verify coverage.

The important part is consistency. Don't let the record end ambiguously, and don't leave stale senders in place.

Can an SPF record be too long

Yes. Long records become hard to manage, easier to break, and more likely to hit practical DNS constraints.

If the TXT value gets lengthy, DNS supports splitting one TXT record into multiple quoted strings within the same record entry. That's different from publishing multiple SPF records. You're still publishing one SPF policy, just represented in DNS as multiple strings that are reassembled by the system.

The operational caution is simple: if the policy is getting long, that's often a sign you should simplify it, not just split it.

Do subdomains help with SPF management

Often, yes.

Subdomains can separate unrelated mail streams so one root domain doesn't have to authorize every sender in the company. That can reduce policy sprawl, limit lookup pressure, and isolate sender reputation between different traffic types.

A common strategy is to keep one domain focused on ordinary organizational mail and use subdomains for other categories such as notifications, campaigns, or application-driven sending. That doesn't eliminate SPF discipline, but it does make the policy easier to reason about.

How do I know whether a service should stay in the record

Ask one question: does this service still send mail using this exact domain?

If the answer is no, remove it after confirming there are no active dependencies. SPF records tend to accumulate old providers because nobody wants to break mail. The safer long-term path is controlled cleanup with testing, not permanent accumulation.

What mistakes show up most often during cleanup

These are the usual ones:

  • Merging syntax incorrectly: Teams paste two full SPF strings together instead of building one policy
  • Forgetting nested lookups: The visible record looks short, but includes expand further
  • Leaving old senders behind: The final policy works, but it's bloated and fragile
  • Changing DNS without testing live senders: Validation passes, then a real workflow fails

Is SPF alone enough

No. SPF is one part of email authentication, not the whole thing.

It helps receivers evaluate whether a sender is authorized for the domain, but it works best alongside DKIM and DMARC. If you're fixing multiple spf records, you're repairing one foundational layer. That's necessary, but it isn't the whole email security model.


If you're building agents that need real inboxes, outbound sending, inbound handling, and custom-domain authentication without bolting together human-centric mail systems, Robotomail is built for that workflow. It gives developers programmatic mailboxes, agent-friendly APIs, and custom domain support so autonomous systems can send and receive email as infrastructure, not as a workaround.