我管理一台运行 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