Postfix

Postfix & Gmail: Authentication Required 錯誤

  • November 5, 2019

我使用本指南配置了 Postfix 。當我發送測試電子郵件時,我收到以下錯誤消息:

May 23 15:36:26 VM11 postfix/smtp[15321]: connect to smtp.gmail.com[2a00:1450:4001:c02::6d]:587: Network is unreachable
May 23 15:36:26 VM11 postfix/smtp[15321]: 4AA58243A3: to=<root@VM11.rbg.informatik.tu-darmstadt.de>, relay=smtp.gmail.com[173.194.70.108]:587, delay=0.07, delays=0.01/0/0.04/0.02, dsn=5.7.0, status=bounced (host smtp.gmail.com[173.194.70.108] said: 530 5.7.0 Must issue a STARTTLS command first. y10sm16916731eev.3 - gsmtp (in reply to MAIL FROM command))
May 23 15:36:26 VM11 postfix/qmgr[15314]: 4AA58243A3: removed

我配置了我的身份驗證數據:

[stmp.gmail.com]:587 USER@GOOGLEDOMAIN:PASSWORD

以下是我的一般配置main.cf

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = VM11.rbg.informatik.tu-darmstadt.de
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = 
relayhost = [smtp.gmail.com]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 51200000
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = all

# Further authentication stuff
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_tls_auth_only = no

那麼配置有什麼問題呢?

編輯:根據 Andrzej A. Filip 的建議,我smtpd_use_tls=yes改為smtp_use_tls. 現在,這給我留下了另一個錯誤消息:

May 26 11:20:36 VM11 postfix/smtp[20031]: D9982243B9: to=<root@VM11.rbg.informatik.tu-darmstadt.de>, relay=smtp.gmail.com[173.194.70.108]:587, delay=0.19, delays=0.02/0/0.15/0.01, dsn=5.5.1, status=bounced (host smtp.gmail.com[173.194.70.108] said: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 z52sm34463651eea.1 - gsmtp (in reply to MAIL FROM command))

我仔細檢查了我的 sasl_password 文件並再次對其進行後映射,但沒有任何成功。

食譜提到smtp_use_tls但你已經設置了smtpd_use_tls

http://mhawthorne.net/posts/postfix-configuring-gmail-as-relay.html 疑難解答 / 1. 無 TLS

嘗試以下在 Ubuntu 18.04 中對我有用的修改版本(假設從頭開始,替換vinano或任何您熟悉的編輯器):

以 root 身份完成這些步驟。

  1. apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules

注意:如果在終端提示問題,請選擇“網際網路站點”和其他預設選項。dpkg-reconfigure postfix如果需要重新配置後綴,請執行。 2. 創建您的密碼文件vi /etc/postfix/sasl_passwd 3. 填充密碼文件。例子:[smtp.gmail.com]:587 myusername@gmail.com:mypassword 4. 通過執行保護文件chmod 600 /etc/postfix/sasl_passwd 5. 通過執行替換配置文件的內容vi /etc/postfix/main.cf 6. 將以下內容放入文件中:

relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options =
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
  1. 通過執行對密碼文件進行編碼postmap /etc/postfix/sasl_passwd
  2. postfix通過執行重新啟動服務systemctl restart postfix.service
  3. you@example.com在以下程式碼中替換為您的電子郵件並測試發送郵件:echo "Test mail from postfix" | mail -s "Test Postfix" you@example.com
  4. 給Google一點時間來處理。您應該在您的 gmail 帳戶的已發送文件夾和指定目標帳戶的收件箱中看到已發送的郵件。如果郵件沒有收到,請檢查或其他地方cat /var/mail/root具體取決於您的分配是否有錯誤。cat /var/log/mail.log

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