![后缀错误:中继访问被拒绝](https://linux22.com/image/29482/%E5%90%8E%E7%BC%80%E9%94%99%E8%AF%AF%EF%BC%9A%E4%B8%AD%E7%BB%A7%E8%AE%BF%E9%97%AE%E8%A2%AB%E6%8B%92%E7%BB%9D.png)
我无法将邮件发送到外部电子邮件地址(例如 gmail)。
当我尝试使用 telnet 发送邮件时,出现以下错误:
Trying 130.xx.xx.128...
Connected to mydomain.com.
Escape character is '^]'.
220 server2.mydomain.com ESMTP Postfix
mail from: [email protected]
250 2.1.0 Ok
rcpt to: [email protected]
554 5.7.1 <[email protected]>: Relay access denied
这是我的 main.cf 文件:
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
inet_interfaces = all
inet_protocols = all
mydestination = server2.myserver.com, localhost, localhost.localdomain
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debug_peer_level = 2
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
virtual_alias_domains = $virtual_alias_maps
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql-virtual_email2email.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
virtual_mailbox_base = /var/vmail
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, reject_unauth_destination
smtpd_use_tls = yes
smtpd_tls_security_level = may
smtpd_tls_cert_file = /etc/postfix/smtpd.cert
smtpd_tls_key_file = /etc/postfix/smtpd.key
transport_maps = proxy:mysql:/etc/postfix/mysql-virtual_transports.cf
relay_domains = mysql:/etc/postfix/mysql-virtual_relaydomains.cf
relay_recipient_maps = mysql:/etc/postfix/mysql-virtual_relayrecipientmaps.cf
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps
smtpd_sender_restrictions = check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf
smtpd_client_restrictions = check_client_access mysql:/etc/postfix/mysql-virtual_client.cf
maildrop_destination_concurrency_limit = 1
maildrop_destination_recipient_limit = 1
virtual_transport = maildrop
header_checks = regexp:/etc/postfix/header_checks
mime_header_checks = regexp:/etc/postfix/mime_header_checks
nested_header_checks = regexp:/etc/postfix/nested_header_checks
body_checks = regexp:/etc/postfix/body_checks
myhostname = server2.myserver.com
mynetworks = 127.0.0.0/8 [::1]/128
content_filter = amavis:[127.0.0.1]:10024
receive_override_options = no_address_mappings
我应该怎么办?
答案1
理解您的问题的关键是以下两行。
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, reject_unauth_destination
mynetworks = 127.0.0.0/8 [::1]/128
mynetworks
仅列出 localhost,并且连接记录中没有任何内容表明您正在连接到 localhost(事实上,有很多内容表明您没有连接)。并且您没有通过 SASL 进行身份验证。
因此,您几乎肯定会到达reject_unauth_destination
最后,这意味着邮件交易被拒绝。
通过环回接口连接到您的邮件服务器,或者进行扩充mynetworks
以包含您要连接的 IP 地址,或者使用 SASL 向邮件服务器进行身份验证。那么中继会工作得更好。
此外,解决这些问题的一个好地方通常是服务器日志。他们很少不包含有关邮件交易被拒绝的原因的详细信息,并且他们通常会为您指出解决方案。