Can a Domain Have Multiple SPF Records?
Two SPF records on one domain break SPF checks. The standard forbids it, the check returns permerror, and the fix is to merge everything into one record.
A common SPF record question is whether a domain can have two of them. Someone added a new sending tool, pasted the vendor's record, and left the old one in place. The answer is short: no, a domain cannot have more than one SPF record. The standard forbids it, and the check fails in a specific way until you merge them. Here is the rule and the fix. See what an SPF record is if you want the basics first.
Can a domain have more than one SPF record?
No. SPF's standard says multiple SPF records are not permitted for the same owner name. It also says a domain name must not have multiple records that would cause an authorization check to select more than one record.
The reason is structural. SPF works by having the receiver fetch one record and walk its terms from left to right. With two records, the receiver sees two different policies and has no rule for choosing one over the other. So the standard does not allow the situation to arise. One domain, one record.
What happens when two SPF records exist
The check is not kind about it. SPF's standard says records that do not begin with a version section of exactly v=spf1 are discarded. If both of your records start with v=spf1, neither is discarded. SPF's standard says check_host produces permerror when more than one record remains.
Permerror is the worst result you can publish your way into. SPF's standard says a permerror result means the domain's published records could not be correctly interpreted. It also says permerror signals an error that definitely needs DNS operator intervention to be resolved.
The receiver learns nothing from a permerror. SPF's standard says a permerror result gives no true indication about whether the envelope data was authorized. Your mail is neither passed nor failed. SPF's standard says the action to take is determined by the local policies of the receiver. See SPF failure results for how receivers treat each outcome.
Why people end up with two records
A common pattern is this. A new tool starts sending mail for the domain, and its setup page says to publish this record. The person doing the setup does not find the existing record, so they add a second TXT record instead of editing the first.
The vendor's instruction is not wrong. It just assumes you will merge it into your existing record rather than paste it alongside. Some DNS panels make this easy to do by accident. Adding a new TXT record is a one-click form, while editing the old one takes a search.
How to merge SPF records into one
Pull the mechanisms out of each record and combine them into a single string. Keep one v=spf1 at the start and one all at the end. Delete the second record entirely.
Say you have these two records:
v=spf1 include:spf.mailhost.example ~all
v=spf1 include:spf.esp.example ~all
The merged record is:
v=spf1 include:spf.mailhost.example include:spf.esp.example ~all
One version section, one all mechanism, everything else in between. Do not keep two all mechanisms, and do not keep two v=spf1 strings. If you want the syntax rules in full, read SPF record syntax.
A common question here is whether you can keep one record for marketing mail and another for transactional mail. You cannot. SPF checks the domain, not the campaign. When both kinds of mail use the same MAIL FROM domain, both hit the same record. Merge them.
The include mechanism and the 10-lookup limit
The merge has a cost. SPF's standard says the include mechanism is intended for crossing administrative boundaries. Each include points at someone else's record, and evaluating it means more DNS queries.
SPF's standard says implementations must limit the total number of terms that cause DNS queries to 10 during SPF evaluation. The include, a, mx, ptr, and exists mechanisms and the redirect modifier all count. SPF's standard says this is a single global limit across all evaluations, so nested includes inside includes count too. If the limit is exceeded, the implementation must return permerror.
So every include you add in the merge spends from the same budget of 10. A merged record with many includes can fail even though it is valid syntax. SPF's standard says it is better to use less resource-intensive mechanisms like ip4 and ip6 over a, or a over mx. The ip4, ip6 and all mechanisms cause no DNS queries at all during evaluation.
include versus redirect
These two get confused because both point at another record. They do different jobs. Include crosses administrative boundaries, so you can pull in a vendor's policy. Redirect works within one administrative domain. SPF's standard says redirect is more suitable for sharing authorizations and policy within one administrative domain.
The common use case is a set of domains that share one mail system. SPF's standard says they can all use that mail system's SPF record through redirect. Each domain publishes a short record that redirects to the shared one. SPF's standard says only the mail system's record needs updating when the mail setup changes, so the domains' own records never change.
One caution. SPF's standard says any redirect modifier must be ignored if there is an all mechanism anywhere in the record. A record with both does not do what you think. Pick one. The standard says it is better to use either a redirect modifier or an all mechanism to explicitly terminate processing.
How to check your record before and after
Query the name for TXT records only. SPF's standard says the DNS query for an SPF record is made for the name, querying for type TXT only. The old SPF record type, code 99, has been removed from the protocol, and records must be published as TXT only. More on that in DNS and SPF records.
One thing that trips people up: a single TXT record can hold multiple character strings. That is not two SPF records. SPF's standard says a published record with multiple character-strings must be treated as if those strings are concatenated together without adding spaces. Some DNS control panels break a long record into separate strings for you. That is fine. Two separate TXT records, each with its own v=spf1, is not fine.
When your merged record still fails
Two causes remain after the merge. First, syntax errors. SPF's standard says check_host returns permerror right away if the SPF record has any syntax errors. A missing space or a stray quote will do it.
Second, the lookup limit. If your merged record has too many includes, the 10-query budget runs out and the result is permerror again. The fix is flattening: replace includes with the ip4 and ip6 ranges the vendor publishes, so no extra DNS queries happen. Check the vendor's documentation for its current ranges, and recheck after you flatten, because vendors change their ranges.
A domain that sends no mail needs none of this. SPF's standard gives the record for that case as v=spf1 -all, and publishing it is best practice. For how SPF fits with DKIM and DMARC, see SPF, DKIM and DMARC.
Sources
Filed