Skip to content

Multiple SPF records: merge them and clear the SPF PermError

Multiple SPF records on one domain make receivers return spf=permerror, even when each record is correct on its own. Find which TXT records are real duplicates, merge them into one and replace them in Cloudflare or Route 53.

Offensly Team··5 min read

A message header from Microsoft 365 shows spf=permerror, a checker says your domain has multiple SPF records, and nothing about your sending setup changed except one new service. That new service is usually the cause. A domain may publish only one SPF record, and when a receiver finds two, it does not pick one. It stops.

Authentication-Results: spf=permerror (sender IP is 192.0.2.10)
 smtp.mailfrom=example.com; dkim=pass (signature was verified)
 header.d=example.com; dmarc=pass action=none header.from=example.com

RFC 7208, section 4.5 is blunt about it: the receiver keeps only TXT records that start with exactly v=spf1, and if more than one is left, the result is permerror. It does not matter that both records are valid on their own, or that one of them lists the IP address that sent the message.

Query the name the receiver actually checks

SPF is checked against the envelope sender, the smtp.mailfrom domain in the header above, not the From: address people see. If smtp.mailfrom says bounce.example.com, query that name. Records on example.com play no part for that message.

$ dig TXT example.com +short
"google-site-verification=PLACEHOLDER-not-a-real-token"
"MS=ms00000000"
"v=spf1 include:spf.protection.outlook.com -all"
"v=spf1 include:_spf.google.com ~all"

Each line of +short output is a separate TXT record. Here there are four, and two of them start with v=spf1. That is the problem. The verification tokens are not SPF records and do not count against you; deleting them only breaks the service that asked for them.

Now compare with this output:

$ dig TXT example.com +short
"v=spf1 ip4:192.0.2.0/24 include:spf.protection.outlook.com " "include:_spf.google.com -all"

This is one record split into two strings on one line. That is legal, and receivers join the strings without adding anything between them (RFC 7208, section 3.3). Note the space before the closing quote of the first string. Without it the joined record reads outlook.cominclude: and fails as a syntax error, which is also a permerror but a different bug.

These are not duplicates: a v=spf1 record on a subdomain such as mail.example.com, your DMARC record at _dmarc.example.com, and an old record of the obsolete SPF type (type 99). Receivers only query TXT, and RFC 7208 section 3.1 discontinued the separate type. You can delete a type 99 record, but it is not what causes the error.

Which of the three usual causes you have

A second service was added next to the first. The most common one. A vendor's setup page said "add this TXT record", and someone added it instead of merging. The two records list different includes, as in the first output above.

One long record became two. The two records look like halves of one: the first has no all at the end, and the second repeats v=spf1 in front of the remaining includes because a checker or panel complained without it. In the Route 53 console, every line in the Value box is a separate record value, so a record wrapped onto two lines turns into two records. If the second half has no v=spf1, you get no permerror, just a quieter bug: receivers discard that half and its includes never count. AWS says to keep all strings on the same line, each in quotes, separated by a space (AWS re:Post).

An old record survived a migration. One record matches the provider you send through today, the other lists a server or hosting platform you left. Check with whoever owns that platform before you drop it: a contact form or invoicing tool may still send through it.

Merge multiple SPF records into one

  1. Collect every mechanism from all v=spf1 records: each include:, ip4:, ip6:, a and mx.
  2. Drop exact duplicates and anything you confirmed is no longer in use.
  3. Write one record: v=spf1 first, the mechanisms in any order, and a single all at the end. For Microsoft 365 and Google Workspace together:
example.com.  3600  IN  TXT  "v=spf1 include:spf.protection.outlook.com include:_spf.google.com -all"
  1. Pick one all. If the old records disagreed (-all in one, ~all in the other), use ~all until you have checked DMARC reports for a week or two and know every sender is listed, then move to -all. Microsoft's own example uses -all; Google's uses ~all. Both work under DMARC, so this choice matters less than having one record.
  2. Count the lookups. Merging adds every include to one evaluation, and more than ten DNS lookups is a permerror of its own. If you get close, the article on the SPF 10 lookup limit shows how to cut it down.

Microsoft and Google say the same thing in their setup docs: edit the existing record, do not create a second one (Microsoft 365, Google Workspace).

Replace the records in your DNS panel

Edit the record you keep first, then delete the other. Until the second step you still have the same permerror as before; the reverse order instead leaves a window where the senders from the deleted record fail SPF outright.

Cloudflare. Open DNS > Records, select Edit on the v=spf1 record you keep, paste the merged value and select Save. On the second record, select Edit, then Delete, and confirm with Delete (Cloudflare docs).

Amazon Route 53. Open Hosted zones, choose the zone, select the TXT record for the name and choose Edit record. Route 53 keeps all TXT values for one name in a single record set, so the duplicate SPF is usually a second line in the same Value box. Leave the verification lines alone, delete the second v=spf1 line and keep the merged record on one line.

Other panels follow the same pattern; the step-by-step guide to adding DNS records covers where the TXT editor sits in the common ones.

Why mail still arrives with spf=permerror, and when it stops

In the header at the top, DMARC passed even though SPF failed. DMARC needs one aligned pass from SPF or DKIM (RFC 7489, section 4.2), and DKIM carried it. That is why this error can sit unnoticed for months. It bites the senders that do not sign with your domain, often the newly added service itself, and once you move from DMARC p=none to enforcement, their mail goes to spam or bounces. The fix is a five-minute DNS edit; the cost of leaving it is losing mail from the tool you just paid for.

Check the fix after the TTL

Receivers cache the old answer until its TTL runs out, so wait at least that long (the second column of dig TXT example.com without +short). Then:

$ dig TXT example.com +short | grep -c '"v=spf1'
1

Exactly 1. Send a test message through each service and look for spf=pass with the right smtp.mailfrom in Authentication-Results. The free Offensly check reads your SPF record together with DKIM, DMARC and MX, no account needed, so you can confirm the zone now serves one record.

Check your SPF record for free

Check your own domain in seconds

The free check reads your SPF, DKIM, DMARC and MX records and tells you exactly what to fix. No sign-up.