Postfix smtp 郵件無法傳送到外部主機

Postfix smtp 郵件無法傳送到外部主機

我管理一台運行 Web 伺服器和郵件伺服器的伺服器(Ubuntu 12.04 LTS) - Web 伺服器運行一切正常,但郵件伺服器有問題。我已經正確安裝和設定了 Dovecot - 我可以使用 Thunderbird 連接到它(我的客戶端位於另一個網路中,因此它不是內部網路)並查看所有資料夾等。

Postfix smtp 驗證似乎可以工作(使用 STARTTLS),因為我可以將外部網路中的 Thunderbird 的電子郵件寫入本機主機和伺服器的網域。但是,當我嘗試將電子郵件發送到另一個地址(例如 gmail)時,出現以下錯誤:

An error occurred while sending mail. The mail server responded:  5.7.1 <***@gmail.com>:
Relay access denied. Please check the message recipient ***@gmail.com and try again.

我在 postfix 本身上使用 smtp 中繼,當我使用 ssh 登入時,我可以寫電子郵件。我認為問題出在這裡 - 到 postfix 的 smtp 連接也使用這個配置的中繼嗎?

這是我的 main.cf:(主機名稱、網域等由虛構資料替換)

# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
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 = mydomain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = mydomain.com, localhost, myhostname
relayhost = smtp.myrelayhoster.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all



smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noplaintext noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password

sender_canonical_maps = hash:/etc/postfix/sender_canonical

如前所述,基本的 smtp 身份驗證似乎正在工作 - 是否需要為 smtp 單獨配置中繼?

這些是 /var/log/mail.log 的重要行:

Sep  5 09:19:21 myhostname postfix/smtpd[9086]: connect from isp-ip.net[123.456.789.123]
Sep  5 09:19:22 myhostname postfix/smtpd[9086]: NOQUEUE: reject: RCPT from isp-ip.net[123.456.789.123]: 554 5.7.1 <[email protected]>: Relay access denied; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<thunderbird>
Sep  5 09:19:22 myhostname postfix/smtpd[9086]: disconnect from isp-ip.net[123.456.789.123]

答案1

Sep  5 09:19:22 myhostname postfix/smtpd[9086]: NOQUEUE: reject: RCPT from isp-ip.net[123.456.789.123]: 554 5.7.1 <[email protected]>: Relay access denied; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<thunderbird>

嘗試透過 telnet 模擬 smtp 會話並將輸出新增至問題。你也可以使用 swaks,它只是一個 perl 腳本

# swaks -s isp-ip.net --helo thunderbird --to [email protected] --from [email protected] --auth PLAIN --auth-user [email protected] --auth-password 7654321 --auth-hide-password

主機未通告身份驗證

看來中繼主機不支援身份驗證。可能是這樣,但只能透過加密通道。嘗試使用 465/587 連接埠代替,例如

# swaks -s isp-ip.net -tlsc -p 465 --helo thunderbird --to [email protected] --from [email protected] --auth PLAIN --auth-user [email protected] --auth-password 7654321 --auth-hide-password

# swaks -s isp-ip.net -tls -p 587 --helo thunderbird --to [email protected] --from [email protected] --auth PLAIN --auth-user [email protected] --auth-password 7654321 --auth-hide-password

相關內容