发送到外部电子邮件时 Postfix 中继访问被拒绝

发送到外部电子邮件时 Postfix 中继访问被拒绝

我有一个问题。我正在尝试使用 POSTFIX 创建自定义 SMTP 服务器。

我使用连接到服务器

openssl s_client -starttls smtp -connect mx.mydomain.com:587

输入“rcpt to:”后,出现错误“中继访问被拒绝”

250 SMTPUTF8
mail from: [email protected]
250 2.1.0 Ok
rcpt to: [email protected]
454 4.7.1 <[email protected]>: Relay access denied

这是来自服务器的错误日志

Dec 29 12:03:04 ubuntu-bionic-1 postfix/smtpd[21858]: connect from 89-212-163-121.dynamic.t-2.net[89.212.163.121]
Dec 29 12:03:04 ubuntu-bionic-1 postfix/smtpd[21858]: Anonymous TLS connection established from 89-212-163-121.dynamic.t-2.net[89.212.163.121]: TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)
Dec 29 12:03:38 ubuntu-bionic-1 postfix/smtpd[21858]: NOQUEUE: reject: RCPT from 89-212-163-121.dynamic.t-2.net[89.212.163.121]: 454 4.7.1 <[email protected]>: Relay access denied; from=<[email protected]> to=<[email protected]> 
proto=ESMTP

这是 postconf 的输出

postconf -n
postconf: warning: /etc/postfix/master.cf: undefined parameter: mua_client_restrictions
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
compatibility_level = 2
home_mailbox = Maildir/
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 50000000
mydestination = $myhostname, myDomain.com, ubuntu-bionic-1.europe-west6-a.c.test-smtp-263411.internal, localhost.europe-west6-a.c.test-smtp-263411.internal, localhost
myhostname = ubuntu-bionic-1.europe-west6-a.c.test-smtp-263411.internal
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_cert_file = /etc/ssl/certs/cert.pem
smtp_tls_key_file = /etc/ssl/private/pvt.key
smtp_tls_loglevel = 1
smtp_tls_mandatory_protocols = !SSLv2,!SSLv3
smtp_tls_note_starttls_offer = yes
smtp_tls_protocols = !SSLv2,!SSLv3
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/cert.pem
smtpd_tls_key_file = /etc/ssl/private/pvt.key
smtpd_tls_loglevel = 1
smtpd_tls_mandatory_protocols = !SSLv2,!SSLv3
smtpd_tls_protocols = !SSLv2,!SSLv3
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
virtual_alias_maps = hash:/etc/postfix/virtual

这是 master.cf 的输出

smtp      inet  n       -       y       -       -       smtpd
submission inet n       -       y       -       -       smtpd
#  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_tls_auth_only=yes
#  -o smtpd_reject_unlisted_recipient=no
  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=
#  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
pickup    unix  n       -       y       60      1       pickup
cleanup   unix  n       -       y       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
tlsmgr    unix  -       -       y       1000?   1       tlsmgr
rewrite   unix  -       -       y       -       -       trivial-rewrite
bounce    unix  -       -       y       -       0       bounce
defer     unix  -       -       y       -       0       bounce
trace     unix  -       -       y       -       0       bounce
verify    unix  -       -       y       -       1       verify
flush     unix  n       -       y       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       y       -       -       smtp
relay     unix  -       -       y       -       -       smtp
        -o syslog_name=postfix/$service_name
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       y       -       -       showq
error     unix  -       -       y       -       -       error
retry     unix  -       -       y       -       -       error
discard   unix  -       -       y       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       y       -       -       lmtp
anvil     unix  -       -       y       -       1       anvil
scache    unix  -       -       y       -       1       scache
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix  -       n       n       -       2       pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

知道我做错了什么导致中继失败吗?

答案1

我认为这是以下设置:

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination

http://www.postfix.org/postconf.5.html#defer_unauth_destination

为了测试目的,您可以defer_unauth_destination从配置中删除:

/etc/postfix/main.cf

改变:

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination

到:

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated

并重新启动postfix服务

service postfix restart

相关内容