Introduction
A domain must have exactly one SPF record. If it publishes two or more TXT records that start with v=spf1, receivers return permerror and SPF fails for every message, not just for the services in the second record. The fix is to merge all mechanisms into one record, keep it within the 10 DNS lookup limit and end it with a single all.
Duplicate SPF records usually appear when a vendor's setup guide says "add this TXT record" and someone does exactly that. This article shows how to recognise the problem, merge the records step by step and confirm in DMARC reports that SPF passes again. For SPF itself, see what is SPF and why does it matter for DMARC, and for the bigger picture, the DMARC guide.
Key takeaways
- RFC 7208 Section 4.5: more than one SPF record means
permerror. SPF then gives no pass for any sender. - DMARC can still pass through aligned DKIM, which is why the problem can go unnoticed for months.
- Merge by combining every mechanism into one
v=spf1record with oneallat the end. - Count DNS lookups after merging: the limit is 10, and void lookups should stay at 2 or fewer.
- Long records can be split into several quoted strings inside one TXT record. That is not the same as two records.
What happens when a domain has two SPF records?
SPF fails for all mail from that domain. RFC 7208, Section 4.5, says that if the record set "includes more than one record, check_host() produces the 'permerror' result". Section 3.2 is just as clear: a domain name must not have multiple records that would make a check select more than one.
Receivers do not pick the record that matches, and they do not combine them. A domain with these two records gets permerror for its Microsoft 365 mail as well as for its newsletter platform:
example.com. TXT "v=spf1 include:spf.protection.outlook.com -all"
example.com. TXT "v=spf1 include:servers.mcsv.net ~all"
Other TXT records on the same name, such as domain verification tokens, are not a problem. Only records that begin with v=spf1 count.
How does a duplicate SPF record affect DMARC?
DMARC needs SPF or DKIM to pass and align. With SPF at permerror, the only route left is aligned DKIM. Messages from services that sign with the client's own domain still pass DMARC; messages from services that rely on SPF alone fail.
That is why duplicates hide. A Microsoft 365 tenant with DKIM enabled keeps passing DMARC, so nobody notices, until a scanner, a billing system or a relay that only has SPF starts failing. At p=quarantine or p=reject, that mail goes to junk or bounces. In aggregate reports, look for permerror in the SPF result for every source, including the ones you know are legitimate. Common DMARC errors and how to fix them explains permerror and temperror side by side.
How do you find duplicate SPF records?
Query the TXT records for the domain and count the ones that start with v=spf1:
$ dig +short TXT example.com
"MS=ms12345678"
"v=spf1 include:spf.protection.outlook.com -all"
"v=spf1 include:servers.mcsv.net ~all"
Two lines starting with v=spf1 means two records. Check the envelope domains your senders use as well, not just the main domain: a return-path subdomain such as bounce.example.com can carry its own duplicate. Our free SPF analyzer and DNS lookup tool show the same result without a command line.
How do you merge two SPF records into one?
Combine every mechanism into a single record, remove duplicates, and keep one all at the end. Work in this order:
- List every mechanism from all the records: each
include:,ip4:,ip6:,a,mxand anyredirect=. - Remove the ones nobody uses any more. Check each against the DMARC aggregate reports; a service that has not sent in months is a candidate to drop.
- Remove exact duplicates that appear in both records.
- Choose one
allqualifier. If the records disagree (-allin one,~allin the other), pick the one that matches your policy. Under DMARC,~allis acceptable, because the DMARC policy decides what happens to failing mail. - Count the DNS lookups in the merged record (see below).
- Publish the merged record and delete the old ones in the same change, so there is never a moment with two records or with none.
The two records above merge into this:
example.com. TXT "v=spf1 include:spf.protection.outlook.com include:servers.mcsv.net -all"
A redirect= modifier cannot simply be appended: it only takes effect when no mechanism matches, and it is ignored if the record contains an all mechanism. If one of the records uses redirect=, replace it with an include: of the same domain in the merged record.
How many DNS lookups can the merged record use?
Ten. RFC 7208, Section 4.6.4, limits the mechanisms and modifiers that trigger DNS lookups (include, a, mx, ptr, exists and redirect) to 10 per evaluation, and each include: counts its own nested lookups too. Going over the limit also produces permerror, so a merge that fixes one problem can create the other.
| Mechanism | Counts towards the 10? | Notes |
|---|---|---|
include: |
Yes, plus every lookup inside it | The usual cause of going over |
a, mx |
Yes | mx also resolves each MX host |
redirect= |
Yes | Replace with include: when merging |
ptr |
Yes | Avoid; RFC 7208 discourages it |
exists |
Yes | Rare in practice |
ip4:, ip6:, all |
No | No DNS lookup needed |
RFC 7208 also says implementations should limit "void lookups", queries that return no answer, to two. An include: for a vendor domain that no longer publishes SPF is a void lookup. If the merged record is over budget, move some senders to their own return-path subdomain, each with its own record and budget. SPF too many DNS lookups covers the options, and SPF flattening explained explains why flattening needs care.
Is a long SPF record split into strings the same as two records?
No. A single TXT record may contain several quoted strings, and RFC 7208, Section 3.3, says they are joined together without spaces before evaluation. That is still one record:
example.com. TXT ( "v=spf1 include:spf.protection.outlook.com include:servers.mcsv.net "
"ip4:203.0.113.0/24 -all" )
Each string can be at most 255 characters, so long records have to be split this way. Note the space at the end of the first string; without it, two mechanisms would run together. Section 3.4 also advises keeping the DNS answer small enough to fit in 512 octets. Some DNS hosting panels show each string as a separate line, which makes one record look like two; check the raw query output if in doubt.
How do you stop duplicates coming back?
Make SPF changes go through one owner. Duplicates return when each vendor's onboarding guide tells someone to "add a TXT record", and that person adds a new record instead of editing the existing one.
For an MSP, three habits prevent it:
- One change process for SPF per client, with the current record documented in the sender inventory described in DMARC client discovery.
- Alerting on SPF results in DMARC monitoring, so a jump in
permerroracross all sources is caught within a day. - A DNS check after every vendor onboarding, counting
v=spf1records and lookups before closing the ticket.
FAQ
Can a domain have two SPF records?
No. RFC 7208 says a domain must not publish more than one SPF record, and receivers return permerror when they find two or more. Merge them into one record.
Which SPF record do receivers use if there are two?
Neither. Receivers do not choose between them or combine them; the check ends with permerror, so SPF does not pass for any message from the domain.
Does a subdomain count as a second SPF record?
No. Each domain name has its own SPF record. example.com and mail.example.com can each publish one record without conflict, which is also how you give heavy senders their own lookup budget.
Will merging SPF records break anything?
Not if every mechanism from the old records is kept or deliberately removed, and the lookup count stays at 10 or fewer. Publish the merged record and remove the old ones in one change, then check the aggregate reports over the following days.
Do I need -all or ~all in the merged record?
Either works with DMARC. DMARC's own policy decides how receivers treat failing mail, so ~all is acceptable, as long as there is exactly one all at the end of the single record. For the trade-offs, including early rejection of forwarded mail with -all, see SPF ~all vs -all with DMARC.
Final thoughts
Two SPF records are one of the easiest DNS mistakes to make and one of the easiest to fix, but they quietly turn every SPF check into a failure. Count the v=spf1 records on every sending domain, merge them into one within the lookup budget, and make sure the next vendor onboarding edits that record instead of adding another.