![Redhat EL 7.2 使用 postfix 使用 smtp.gmail.com 进行中继不起作用](https://linux22.com/image/685693/Redhat%20EL%207.2%20%E4%BD%BF%E7%94%A8%20postfix%20%E4%BD%BF%E7%94%A8%20smtp.gmail.com%20%E8%BF%9B%E8%A1%8C%E4%B8%AD%E7%BB%A7%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8.png)
我正在运行rhel 7.2
,我已postfix
安装但无法通过 gmail smtp 服务器进行中继。我已遵循许多教程并在 Google 上搜索并尝试回答许多其他帖子,但似乎无法让任何事情正常工作。
这是我当前遇到的错误/var/log/maillog
(为了保护隐私,我将主机名和电子邮件地址替换为 x:
Jun 30 16:35:15 xxxxxxxx postfix/qmgr[31716]: 1DC08C13E1CA: from=<[email protected] >, size=277, nrcpt=1 (queue active)
Jun 30 16:35:15 xxxxxxxx postfix/smtp[31846]: 1DC08C13E1CA: to=<[email protected]>, relay=smtp.gmail.com[173.194.193.109]:587, delay=3512, delays=3512/0.02/0.31/0.04, d sn=5.5.1, status=bounced (host smtp.gmail.com[173.194.193.109] said: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/answer/14 257 z205sm11773703itc.11 - gsmtp (in reply to MAIL FROM command))
Jun 30 16:35:15 inigo postfix/cleanup[31848]: 9544CC13E1CF: message-id=<2016063022351 5.9544CC13E1CF@inigo>
Jun 30 16:35:15 xxxxxxxx postfix/bounce[31847]: 1DC08C13E1CA: sender non-delivery notifi cation: 9544CC13E1CF
Jun 30 16:35:15 xxxxxxxx postfix/qmgr[31716]: 9544CC13E1CF: from=<>, size=2283, nrcpt=1 (queue active)
Jun 30 16:35:15 inigo postfix/qmgr[31716]: 1DC08C13E1CA: removed
Jun 30 16:35:15 inigo postfix/smtp[31846]: 9544CC13E1CF: to=<[email protected]>, relay=smtp.gmail.com[173.194.193.108]:587, delay=0.32, delays=0.01/0/0.28/0.03, dsn= 5.5.1, status=bounced (host smtp.gmail.com[173.194.193.108] said: 530-5.5.1 Authentic ation Required. Learn more at 530 5.5.1 https://support.google.com/mail/answer/14257 p131sm3141384itg.17 - gsmtp (in reply to MAIL FROM command))
Jun 30 16:35:15 xxxxxxxxxx postfix/qmgr[31716]: 9544CC13E1CF: removed
我尝试了网上的多种解决方案,我的/etc/postfix/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 = xxxxxxxx
myorigin = $myhostname
inet_interfaces = 10.10.10.10,127.0.0.1
inet_protocols = ipv4
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
mynetworks = 127.0.0.0/8, 10.10.10.0/24
relayhost = [smtp.gmail.com]:587
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
home_mailbox = Maildir/
smtpd_banner = $myhostname ESMTP
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
message_size_limit = 10485760
mailbox_size_limit = 1073741824
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtp_sasl_local_domain = $myhostdomain
smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject
smtp_use_tls = yes
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
smtp_sasl_password_maps = hash:/etc/postfix/sasl/passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
smtp_tls_security_level = secure
smtp_tls_mandatory_protocols = TLSv1
smtp_tls_mandatory_ciphers = high
smtp_tls_secure-cert_match = nexthop
smtp_tls_CApath = /etc/ssl/certs
smtpd_tls_CAfile = /etc/postfix/cacert.pem
debug_peer=smtp.gmail.com
debug_peer_level=3`
顺便说一下是该文件postfix
的所有者/etc/postfix/sasl/passwd
如果有人有任何建议我将不胜感激!!!
答案1
检查格式是否/etc/postfix/sasl/passwd
正确。
它应该显示为:
smtp.gmail.com [email protected]:password_or_app_password
设置此文件后,您需要运行postmap
它来更新哈希。
postmap /etc/postfix/sasl/passwd
然后重新加载 postfix。
systemctl reload postfix
答案2
我得到了一些帮助,他们发现 passwd 文件没有像 main.cf 文件那样在 smtp.gmail.com 周围加括号,所以我修改了它并使用 postmap 重新映射,然后它给了我一个不同的错误,提到没有可用的有价值的机制,所以我进行了谷歌搜索,发现其他人也遇到了同样的错误,只是安装了 cyrus-sasl-plain 就解决了问题。感谢大家的帮助。