Friday, 12 April 2013

Problems Sending to Gmail With Postfix

When I've been expecting to receive a logwatch summary, or any mail for that matter, from my OpenSuse system I've noticed that nothing is being sent. I've got a couple of other systems that can successfully send infomation to my email address so I was fairly confident it wasn't being blocked by Google. Looking in /var/log/mail I could see the following:

 2013-04-03T21:02:53.774099+01:00 linux-b1bm postfix/smtp[8724]:  
 connect to[2a00:1450:400c:c00::1b]:25:   
 Network is unreachable  

A bit of quick googling led me to a solution. I needed to make a change to my Postfix configuration file, located at /etc/postfix/, and prevent it from trying IPv6 first when looking up Google's SMTP server. We can see the IPv6 address in the error message - 2a00:1450:400c:c00::1b.

In my Posfix configuration, I amended the line that says:

 inet_protocols = all 

and changed it to:

 inet_protocols = ipv4  

Next job, restart Postfix

 # /etc/init.d/postfix restart  

Testing to see if the fix has resolved the problem, I manually ran the logwatch command again and then took another peek in /var/log/mail:

 2013-04-11T23:33:14.990331+01:00 linux-b1bm postfix/smtp[30775]: 4B2C21204AB: to=<>,[]:25, delay=0.71, delays=0.04/0.01/0.35/0.31,  
  dsn=2.0.0, status=sent (250 2.0.0 OK 1365719611 bd3si2257919wjb.173 - gsmtp)  

Great success! We can see that it is now using the IPv4 address for Google's SMTP server and it has status=sent.