Postfix:SMTP,使用連接埠 587 而不是 465

Postfix:SMTP,使用連接埠 587 而不是 465

我已經按照 Flurdy 的說明在 AWS EC2 上設定了郵件伺服器:http://flurdy.com/docs/postfix/一切進展順利。

我的問題是,我更願意使用 SMTP 連接埠 587 和 TLS,而不是 465 和 SSL。我相信這是一個相關要求,因為連接埠 465 被認為不適合未來。

Flurdy 網站上的說明旨在允許兩者同時使用,但我無法讓 587 工作! 465 和 SSL 很有魅力。

我還應該提到這個構建使用了 sasl 和 MySQL,我想這就是為什麼當我 Google 錯誤時我沒有找到太多幫助的原因。我相信錯誤存在於 SASL / PAM 領域的某個地方,但我沒有運氣。

以下是一些日誌輸出:

郵件日誌

postfix/smtpd[11328]: connect from MY.ISP.PROVIDER[MY.IP.0.0]
postfix/smtpd[11328]: Anonymous TLS connection established from MY.ISP.PROVIDER[MY.IP.0.0]: TLSv1.2 with cipher AES128-SHA256 (128/128 bits)
postfix/smtpd[11328]: warning: SASL authentication failure: client response doesn't match what we generated (tried bogus)
postfix/smtpd[11328]: warning: MY.ISP.PROVIDER[MY.IP.0.0]: SASL DIGEST-MD5 authentication failed: authentication failure
postfix/smtpd[11328]: warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory
postfix/smtpd[11328]: warning: MY.ISP.PROVIDER[MY.IP.0.0]: SASL LOGIN authentication failed: generic failure
postfix/smtpd[11328]: lost connection after AUTH from MY.ISP.PROVIDER[MY.IP.0.0]
postfix/smtpd[11328]: disconnect from MY.ISP.PROVIDER[MY.IP.0.0]*

我的主人.cf

submission inet n       -       n       -       -       smtpd
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_tls_auth_only=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject_unauth_destination,reject
  -o smtpd_sasl_security_options=noanonymous,noplaintext
  -o smtpd_sasl_tls_security_options=noanonymous

smtps     inet  n       -       -       -       -       smtpd
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_tls_auth_only=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o smtpd_sasl_security_options=noanonymous,noplaintext
  -o smtpd_sasl_tls_security_options=noanonymous

還有其他conf,例如AMAVIS,但我懷疑這一切都可以。

SQL 日誌顯示所有連線和查詢正常運作。

我已經使用 TELNET 進行測試,當我嘗試使用連接埠 587 進行身份驗證時,它只是關閉連接。

這是 EHLO 回應與 25(開啟時)和 587 的區別。這是問題嗎?

$ telnet my.mailserver.com 587
Trying MY.IP.0.0...
Connected to my.mailserver.com.
Escape character is '^]'.
220 MY-EC2-SERVER-NAME.localdomain ESMTP Postfix
EHLO my.mailserver.com
250-MY-EC2-SERVER-NAME.localdomain
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

$ telnet my.mailserver.com 25
Trying MY.IP.0.0...
Connected to my.mailserver.com.
Escape character is '^]'.
220 MY-EC2-SERVER-NAME.localdomain ESMTP Postfix
EHLO my.mailserver.com
250-MY-EC2-SERVER-NAME.localdomain
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN CRAM-MD5 DIGEST-MD5
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

我已多次重新啟動 postfix 和 saslauthd 服務。我還仔細檢查了資料庫中的密碼和使用者名稱。我已經仔細閱讀了說明並檢查了是否有錯誤配置和拼寫錯誤,儘管最終可能會是這樣:-)

伺服器是UBUNTU 13.10

如果我可以提供任何進一步的資訊來幫助調試,請告訴我。

歡迎所有想法!

答案1

我也關注了弗魯迪的教程並且有類似的問題:我只能透過連接埠25(smtpd)發送郵件,但不能透過587(提交)。我發現問題正是在於,根據他的指示,連接埠 25 被配置為在 chroot 中運行,但 587 不是——這似乎是教程中的錯誤。查看 flurdy 說明的這一部分:

預設只啟用普通的 smtp 服務,這很好。但我更喜歡啟用提交(連接埠 587),以便客戶端可以使用它,並且我可以將它們限制為僅使用 TLS。也啟用了 smtps 服務(連接埠 465),以實現與某些舊用戶端(outlook express 等)的兼容性。

在此文字的正下方,您可以找到這一行,聲明提交連接埠的守護程式將不使用 chroot:

submission inet n - n - - smtpd

我知道這一點是因為我的原始/etc/postfix/master.cf文件中有顯示此圖例的註釋:

# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================

提交連接埠選項清單的正下方有以下行,用於設定 smtps(連接埠 465):

smtps inet n - - - - smtpd

從這裡你可以看到它正在使用預設值(我猜這個-標誌意味著它將使用預設值,即使用 chroot)。

好的,然後,當您查看 SASL 身份驗證部分時,其中顯示:

變更 SASLAUTHD 的運作方式:

您可以看到該OPTIONS變數包含以下路徑:

# Switch this to be under postfix's spool
# And add -r so that the realm(domain) is part of the username
OPTIONS="-r -c -m /var/spool/postfix/var/run/saslauthd"

再次,在我最初評論的文件的幫助下/etc/default/saslauthd,我注意到了這個清晰的解釋:

# Other options (default: -c -m /var/run/saslauthd)
# Note: You MUST specify the -m option or saslauthd won't run!
#
# WARNING: DO NOT SPECIFY THE -d OPTION.
# The -d option will cause saslauthd to run in the foreground instead of as
# a daemon. This will PREVENT YOUR SYSTEM FROM BOOTING PROPERLY. If you wish
# to run saslauthd in debug mode, please run it by hand to be safe.
#
# See /usr/share/doc/sasl2-bin/README.Debian for Debian-specific information.
# See the saslauthd man page and the output of 'saslauthd -h' for general
# information about these options.
#
# Example for chroot Postfix users: "-c -m /var/spool/postfix/var/run/saslauthd"
# Example for non-chroot Postfix users: "-c -m /var/run/saslauthd"
#
# To know if your Postfix is running chroot, check /etc/postfix/master.cf.
# If it has the line "smtp inet n - y - - smtpd" or "smtp inet n - - - - smtpd"
# then your Postfix is running in a chroot.
# If it has the line "smtp inet n - n - - smtpd" then your Postfix is NOT
# running in a chroot.
OPTIONS="-r -c -m /var/spool/postfix/var/run/saslauthd"

由於我的OPTIONS變數明確指定了 chroot 情況,因此我剛剛更改了我的提交配置以/etc/postfix/master.cf也使用 chroot。重新啟動伺服器後 - 只是為了確保所有服務都正確重新啟動 - 它就像一個魅力,現在我可以透過連接埠 25 或 587 發送電子郵件。

希望它也能幫助你!我也浪費了不少時間才看到這個…

相關內容