远程服务器上的后缀 SMTP 响应 rcpt(收件人)的 554 中继访问被拒绝。在 SMTP 服务器上工作正常'localhost'



我正试图通过作为smtp服务器运行postfix的远程vm发送电子邮件。

但是,在发送rcpt命令时,我收到了一个554 - Relay access denied错误。

(554, b'5.7.1 <xxxxx@xyz.org>: Relay access denied')

我知道它拒绝了我试图设置为收件人的电子邮件地址,但我不明白为什么。


套接字连接本身建立良好,并且我能够在尝试rcpt之前发送mail cmd。


环境详细信息:

主机:

Windows 7机器/语言:Python 3。

来宾虚拟机:

Docker容器(Ubuntu)VM运行postfixssh,dhcp分配的ip地址为10.35.50.166


这是运行的python代码:

(在主机上):

import smtplib
server = smtplib.SMTP(host='10.35.50.166', port=8025)
server.mail('xxxxx@xyz.org')
(250, b'2.1.0 Ok')
server.rcpt('xxxxx@xyz.org')
(554, b'5.7.1 <xxxxx@xyz.org>: Relay access denied')

从客户机运行时,错误不会发生:

import smtplib
server = smtplib.SMTP(host='localhost', port=8025)
server.mail('xxxxx@xyz.org')
(250, b'2.1.0 Ok')
server.rcpt('xxxxx@xyz.org')
(250, b'2.1.5 Ok')

Postfix在Ubuntu上的默认配置只允许在本地接口(即localhost)上进行中继访问。在其他接口(VM网络)上连接时,需要SMTP身份验证。

因此,您可以将身份验证添加到SMTP呼叫中,也可以将主机ip添加到允许的中继网络中。

要稍后实现,请在/etc/postfix/main.cf文件中找到读取的行

mynetworks = 127.0.0.0/8

并将其更改为

127.0.0.0/8,10.0.0.0/8

然后用重新加载后缀

sudo postfix reload

编辑:或者,您可以将mynetworks_style设置为

mynetworks_style = subnet

请参阅基本配置自述

postfix服务器上的main.cf中将出现配置错误,该错误未将您的本地网络设置为允许中继。

你需要类似的东西

Localnetworks=0.0.0.0/24(您的网络或ip是客户机)

问题已修复。这是我现在使用的配置。由于itchee,问题出现在mynetworks指令上。

# 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 (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 = localhost
#myorigin = $mydomain
#relayhost = $mydomain

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = localdomain, localhost, localhost.localdomain, localhost
relayhost =
#mynetworks = 127.0.0.0/8 [::]/128 [::ffff:127.0.0.0]/104 [::1]/128
mynetworks = 127.0.0.0/8 10.0.0.0/8 172.0.0.0/8 [::]/128 [::ffff:127.0.0.0]/104 [::1]/128

mailbox_size_limit = 0
recipient_delimiter = +

#inet_interfaces = localhost

最新更新