Google SMTP Error PTR 550-5.7.1 IPv6 – Fix for Postfix under Ubuntu Server

Having undelivered mails due to numerous errors is not nice – having all of our sent emails rejected by a particular host is nothing short of a nightmare. Google has a strict policy on deciding whether it would allow a mail to be delivered to one of its’ accounts or not – which is a good thing in general.

Even moreso, by bouncing back the mail it gives a pretty straightforward cause why it had decided in doing so:

dsn=5.7.1, status=bounced (host gmail-smtp-in.l.google.com[] said: 550-5.7.1 [] Our system has detected that 550-5.7.1 this message does not meet IPv6 sending guidelines regarding PTR 550-5.7.1 records and authentication. Please review 550-5.7.1  https://support.google.com/mail/?p=ipv6_authentication_error for more 550 5.7.1 information. – gsmtp (in reply to end of DATA command))

It goes without saying that first and foremost one should always start to resolve the situation by visiting the adequate Google Support Page regarding the IPv6 Authentication. However, making changes to your DNS zone file means that the new information has to propagate itself to the other DNS servers throughout the world – which can be a pretty lengthy amount of time, even with a relatively small amout of TTL.

In most cases the error message should disappear within 2-3 days, but as you can guess by the birth of this post – this wasn’t the case with me. For starters, the message itself has initially disappeared only to be replaced with a generic IPv6 error message. I double checked the PTR records as well along with the necessary SPF records – which lead to nowhere.

Guided by frustration I’ve stumbled upon multiple blog entries and forum posts reciting the same error messages I have seen with the exact same symptoms, so without further ado I’ll summerize what helped me in resolving the issue.

Warning! This method essentially disables the use of IPv6 when sending emails to @gmail accounts which should become troublesome when  the world finally ditches IPv4.

This guide assumes you have an Ubuntu/Debian server up and running with Postfix as the Mail Transport Agent.

  1. Add/edit the following within /etc/postfix/main.cf
    smtp_reply_filter = pcre:/etc/postfix/smtp_reply_filter
  2. Create /etc/postfix/smtp_reply_filter with the following content:
    /^5(\d\d )5(.*information. \S+ - gsmtp.*)/ 4${1}4$2
  3. Be sure to have postfix-pcre installed on your system. If not, then:
    apt-get install postfix-pcre
  4. Restart Postfix for the new config to take effect:
    services postfix restart