Postfix SPF Error postfix-policyd-spf-perl SERVFAIL Workaround


We had an interesting one with Postfix, we were recieving mail fine from all other domains. Then one domain (in this case started not to get through, no changes had been made at our end.

What was happening was that their nameservers were not reporting TXT records properly, rather than reporting nothing or an SPF record we were getting a “SERVFAIL”, the postfix spf script we used then started to block all mail with a temporary error 450.

Obviously they needed to fix their domain, but to workaround I did the below:


Sep 27 09:02:20 oakmail postfix/policy-spf[6114]: : Policy action=DEFER_IF_PERMIT ‘SERVFAIL’ error on DNS ‘SPF’ lookup of ‘’

Sep 27 09:02:20 oakmail postfix/smtpd[6102]: NOQUEUE: reject: RCPT from[]: 450 4.7.1 Recipient address rejected: ‘SERVFAIL’ error on DNS ‘SPF’ lookup of ‘’; proto=ESMTP helo=<>


Edited the /usr/share/perl5/Mail/SPF/ file on the server, and then found this line:

$packet->header->rcode =~ /^(NOERROR|NXDOMAIN)$/

And changed it to:

$packet->header->rcode =~ /^(NOERROR|NXDOMAIN|SERVFAIL)$/

Once done restart the postfix service, then when the sender tried again the messages came through fine. Basically it changed the SERVFAIL from a temporary error to a just ignore and pass the mail anyway type issue.

Leave a Reply

Your email address will not be published. Required fields are marked *