Email errors
SPF PermError: Fix Too Many DNS Lookups and Other Causes
SPF permerror means the receiver could not interpret your SPF record. Check the 10 DNS lookup limit, duplicate records and syntax, then fix the cause.
What this means
SPF permerror means the receiving server could not interpret your domain's SPF record, the DNS record that lists which servers may send its mail. Resending will not clear it, because the record itself must change. Microsoft lists too many DNS lookups and duplicate SPF records as the likely causes.
The bounce wording depends on the mail server. Microsoft documents two texts for the lookup limit: The message exceeded the hop count. and The message required too many lookups. Google warns that a provider's message can even say you have no SPF record when you do.
The receiver decides whether to reject or deliver the message. DMARC, the policy check built on SPF and DKIM, can then pass only through DKIM.
Why it happens
SPF too many DNS lookups
A single SPF check may use at most 10 terms that cause a DNS query: include, a, mx, ptr, exists and redirect. The eleventh returns permerror. ip4, ip6 and all cost nothing.
SPF too many included lookups
Terms inside included records count too, so an include pointing to a record with three more includes costs four. RFC 7208 uses neither "too many DNS lookups" nor "too many included lookups", so the wording depends on the server or tool.
Other causes of permerror
If the count is 10 or lower, look for one of these:
- Two
v=spf1records on one name (multiple SPF records). - A syntax error, such as the space in
include: spf.protection.outlook.com. Receivers validate the whole record first, so every message checked against it is affected. - An
includeorredirectpointing to a name with no SPF record. - An
mxterm that needs more than 10 address lookups. - More than two void lookups (queries that return no data), on receivers that apply the limit RFC 7208 recommends.
fail and softfail mean the record was read and did not authorize the sending server (softfail vs fail).
How to fix it
- Find the domain that was checked. In the
Authentication-Resultsheader, read the domain insmtp.mailfrom=besidespf=permerror. That is the envelope sender (the bounce address), which can differ from the From address. If it belongs to a vendor, ask the vendor to fix it. - Count the lookups. Run the SPF checker on that domain to see each lookup. If the name has two
v=spf1records, merge them into one before deleting the other, then count again. If the total is 10 or lower, fix the matching cause above and go to the last step. - Remove what no longer sends. Delete repeated includes and includes for retired services. Caution: a sender listed only in what you delete stops passing SPF, so check recent DMARC aggregate reports first.
- Review
ptr,aandmx. RFC 7208 saysptrshould not be published. Dropaormxif those hosts send no mail, or useip4:orip6:if their addresses are stable. Caution: any sending server you leave out stops passing SPF. - If still over 10, move a third-party sender to a subdomain.
news.example.comgets its own SPF record with the vendor'sinclude, and its own limit of 10. Caution: publish that record before moving the vendor's envelope sender to the subdomain. Remove theincludefrom the main record only after a test showssmtp.mailfrom=news.example.com,spf=passanddmarc=pass. - Flatten only as a last resort. SPF flattening replaces an
includewith the vendor's IP addresses. Microsoft advises against it forinclude:spf.protection.outlook.comand for any service whose addresses change often. Caution: when a vendor changes an address, that mail stops passing SPF until you update the record. - Publish one record. Edit the existing
v=spf1record and keep itsallterm. Caution: a second record to hold the overflow causespermerrorby itself.
Confirm the fix
- Allow for DNS delay. Google says SPF fixes can take 24 to 48 hours to take effect globally.
- Run the checker again. You want 10 lookups or fewer and a single record.
- Send a test from each service to a mailbox you control. Each must show
spf=pass. - Check the next DMARC aggregate reports. The SPF
resultfor that source should change frompermerrortopass.