Postfix 2.11.3 版本在过去几年中运行完美。我升级到3.4.14版本后,服务器无法再向外部发送电子邮件。
在该mail.err
文件中,我找到了以下行:
postfix/smtpd[1043]: fatal: in parameter smtpd_relay_restrictions or smtpd_recipient_restrictions, specify at least one working instance of: reject_unauth_destination, defer_unauth_destination, reject, defer, defer_if_permit or check_relay_domains
之后,我已将两个参数配置master.cf
为
-o smtpd_recipient_restrictions=reject_unauth_destination
-o smtpd_relay_restrictions=reject_unauth_destination
在 Postfix 2.11 版本中,这两个参数都被注释掉了。
配置完成后,消息消失了,但我在文件mail.err
中发现了另一个错误mail.log
Jun 3 08:01:22 smtp-out postfix/smtpd[19915]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 554 5.7.1 <[email protected]>: Relay access denied; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<[127.0.0.1]>
由于我正在使用sender_dependent_relayhost_maps = hash:/etc/postfix/transport_sender
这两个参数的正确配置是什么(如果这是问题的话)?
这是我的main.cf
文件:
inet_protocols = ipv4
smtpd_banner = Company ESMTP NO UCE/UBE
biff = no
append_dot_mydomain = no
myhostname = smtp-out.company.com
mydomain = company.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = smtp-out.local, localhost.dmz.local.dmz.local, localhost, $mydomain, localhost.$mydomain
relayhost = [mail.external-relayserver.com]
relay_domains =
mynetworks = 192.168.10.0/24, 192.168.15.0/24, 127.0.0.0/8, [::1]/128
header_checks = regexp:/etc/postfix/regexp/header_checks
message_size_limit = 47185920
recipient_delimiter = +
transport_maps = hash:/etc/postfix/transport
undisclosed_recipients_header=
local_recipient_maps =
smtp_tls_security_level=may
smtp_tls_loglevel=1
# relay transport
sender_dependent_relayhost_maps = hash:/etc/postfix/transport_sender
smtp_sender_dependent_authentication = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
default_destination_concurrency_limit = 2
default_destination_rate_delay = 1s
master.cf
文件:
smtp inet n - - - - smtpd
-o smtpd_recipient_restrictions=reject_unauth_destination
-o smtpd_relay_restrictions=reject_unauth_destination
pickup unix n - - 60 1 pickup
cleanup unix n - - - 0 cleanup
qmgr unix n - n 300 1 qmgr
tlsmgr unix - - - 1000? 1 tlsmgr
rewrite unix - - - - - trivial-rewrite
bounce unix - - - - 0 bounce
defer unix - - - - 0 bounce
trace unix - - - - 0 bounce
verify unix - - - - 1 verify
flush unix n - - 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - - - - smtp
relay unix - - - - - smtp
showq unix n - - - - showq
error unix - - - - - error
retry unix - - - - - error
discard unix - - - - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - - - - lmtp
anvil unix - - - - 1 anvil
scache unix - - - - 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
您需要指定谁可以通过您的 postfix 服务器进行中继前这reject_unauth_destination
。
例如,允许您自己的网络通过您的服务器进行中继:
smtpd_relay_restrictions = permit_mynetworks, reject_unauth_destination
或者如果您使用 sasl_authentication:
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated,
reject_unauth_destination
请记住,这些规则是按列出的顺序指定的...因此上述规则允许网络上的客户端无需进行身份验证即可中继邮件。来自网络外部的客户端必须验证自己的身份。其他人的中继尝试都会被拒绝。
顺便说一句,对于像您这样的简单后缀配置,最好将这些选项放在文件中main.cf
,而不是master.cf
.