Linux

Redhat EL 7.2 使用 postfix 使用 smtp.gmail.com 中繼不工作

  • July 6, 2016

我正在執行rhel 7.2,我已經postfix安裝並且無法通過 gmail smtp 伺服器進行中繼。我遵循了很多教程,並在Google上搜尋並嘗試了很多其他文章的答案,但我似乎無法得到任何工作。

這是我目前的錯誤/var/log/maillog(我用 x 替換了主機名和電子郵件地址以保護隱私:

Jun 30 16:35:15 xxxxxxxx postfix/qmgr[31716]: 1DC08C13E1CA: from=<root@xxxxxxxxxx.localdomain >, size=277, nrcpt=1 (queue active)
Jun 30 16:35:15 xxxxxxxx postfix/smtp[31846]: 1DC08C13E1CA: to=<xxxxxxxx@xxxxxx.com>,  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=<root@xxxxxxxxxx.localdomain>,  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文件的所有者

如果有人有任何建議,我將不勝感激!!!

我得到了一些幫助,他們發現 passwd 文件沒有像 main.cf 文件在 smtp.gmail.com 周圍那樣的括號,所以我改變了它並用 postmap 重新映射,然後它給了我一個不同的錯誤,提到不值得機制可用,所以我進行了Google搜尋,發現其他人也有同樣的錯誤,並且剛剛安裝了 cyrus-sasl-plain 並且成功了。感謝所有的幫助。

檢查您的格式/etc/postfix/sasl/passwd是否正確。

它應該顯示為:

smtp.gmail.com     user@gmail.com:password_or_app_password

設置此文件後,您需要在其上執行postmap,以更新雜湊。

postmap /etc/postfix/sasl/passwd

然後重新載入後綴。

systemctl reload postfix

引用自:https://serverfault.com/questions/787272