Problems with Gmail in default Postfix configuration
Recently I moved some of the sites to a new hosting. The previous server had Ubuntu 12.04 with Exim4 and I forgot how to configure them.
On a new server I installed Postfix with Ansible:
- name: Set up Postfix to relay mail
debconf: name=postfix
question='{{ item.question }}'
value='{{ item.value }}'
vtype='{{ item.vtype }}'
with_items:
- { question: 'postfix/mailname', value: '{{ ansible_fqdn }}', vtype: 'string' }
- { question: 'postfix/main_mailer_type', value: 'Internet Site', vtype: 'string' }
After that I started to receive the next delivery reports from Gmail:
Action: failed
Status: 5.7.1
Remote-MTA: dns; gmail-smtp-in.l.google.com
Diagnostic-Code: smtp; 550-5.7.1 This message does not have authentication
information or fails to pass 550-5.7.1 authentication checks. To best
protect our users from spam, the 550-5.7.1 message has been blocked. Please
visit 550-5.7.1
https://support.google.com/mail/answer/81126#authentication for more 550
5.7.1 information. d86si3833724ljf.339 - gsmtp
I solved this with inet_protocols = ipv4
setting in the /etc/postfix/main.cf
. After that, the reports are gone, but some emails started to go to the spam. It can be solved with set up a SPF
, DKIM
, PTR
records and so on. But since I already used Mailgun in one of the projects, I configured Postfix to use it also. It’s just a few lines and everything works.
relayhost = [smtp.mailgun.org]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:postmaster@mydomain.com:password
smtp_sasl_security_options = noanonymous