大网数据广告活动
服务器运维问答

Postfix tls errors with gmail as relayhost

· 52CE 我爱测

while configuring a php contact form ive run into a bizarre issue where postfix refuses to send an email, I've narrowed the errors down to one and occasionally a second which. The first is : from /var/log/maillog connect to smtp.…

问题原文

原帖链接 · Grey · CC BY-SA 4.0

while configuring a php contact form ive run into a bizarre issue where postfix refuses to send an email, I've narrowed the errors down to one and occasionally a second which.

The first is :

from /var/log/maillog

 connect to smtp.gmail.com[2607:f8b0:400d:c03::6c]:587: Network is unreachable
Jun 11 16:57:59 site postfix/smtp[1315]: E79467A7: to=<apache@site.[domain].com>, relay=smtp.gmail.com[173.194.205.109]:587, delay=0.19, delays=0.01/0/0.16/0.02, dsn=5.5.1, status=bounced (host smtp.gmail.com[173.194.205.109] said: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1  https://support.google.com/mail/?p=WantAuthError y131-v6sm20355089qka.30 - gsmtp (in reply to MAIL FROM command))

Allow less secure apps is enabled as recommended in the error log, and I've added tls support in main.cf

dump of main.cf

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
#myhostname = [site].[domain].com
#mydomain = [domain].com
myorigin = $mydomain
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
unknown_local_recipient_reject_code = 550
#mynetworks = <192.168.122.0/24, 192.168.100.0/24, 127.0.0.0/8>
relayhost = [smtp.gmail.com]:587
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases


debug_peer_level = 2
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.10.1/samples
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options =
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
smtp_tls_security_level = encrypt
smtp_tls_CAfile = /etc/pki/tls/cert.pem

I'm not familiar with postfix, how it works, or what it requires. Any help would be appreciated.

已采纳解答

原帖链接 · silmaril · CC BY-SA 4.0

As for the first message:

connect to smtp.gmail.com[2607:f8b0:400d:c03::6c]:587: Network is unreachable

This means that the network configuration of your server doesn't allow postfix to reach an IPv6 address, but that you configured postfix to try and use IPv6.

You should check your host configuration and eventually if you don't have access to an IPv6 network, disable ipv6 processing in postfix:

postconf -e inet_protocols=ipv4

As for the second:

Jun 11 16:57:59 site postfix/smtp[1315]: E79467A7: to=<apache@site.[domain].com>, relay=smtp.gmail.com[173.194.205.109]:587, delay=0.19, delays=0.01/0/0.16/0.02, dsn=5.5.1, status=bounced (host smtp.gmail.com[173.194.205.109] said: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1  https://support.google.com/mail/?p=WantAuthError y131-v6sm20355089qka.30 - gsmtp (in reply to MAIL FROM command))

The message can be read like this:

  • relay=smtp.gmail.com[173.194.205.109]:587, delay=0.19, delays=0.01/0/0.16/0.02
    • Postfix sent the mail to the relay host specified
  • dsn=5.5.1, status=bounced
    • The host refused to handle the message
  • host smtp.gmail.com[173.194.205.109] said: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/?p=WantAuthError y131-v6sm20355089qka.30 - gsmtp (in reply to MAIL FROM command)
    • This is an explaination sent by the relayhost you use for the rejection. In this case it's google way of saying that you didn't send an login/password to authenticate on the relay, or that the login/password used is incorrect.

To explain/help you further the content of /etc/postfix/sasl_passwd and /etc/postfix/tls_policy would be useful.

/etc/postfix/sasl_passwd should contain a line like that

smtp.gmail.com <gmail-accound-username>:<gmail-password>

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-06-11)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。