如何纠正Postfix''中继访问被拒绝'?
今天上午,为了纠正安全证书中名称不匹配的问题,我按照如何修复邮件服务器SSL?中推荐的步骤,但现在,当试图从客户端(本例中的客户端是Windows Mail)发送电子邮件时,我收到了以下错误。
被拒绝的电子邮件地址是 'email@gmail.com'。主题 '这是一个 测试。 ',账户:'mail.domain.com'、 服务器: 'mail.domain.com', 协议: SMTP, 服务器响应: '554 5.7.1 email@gmail.com:中继访问 denied', 端口: 25, Secure(SSL):No、 服务器错误:554, 错误号码: 0x800CCC79
编辑:我仍然可以从这个账户中检索到电子邮件,并且可以向同一域名的其他账户发送电子邮件。我只是不能向我们域外的收件人发送电子邮件。
我试着完全禁用TLS,但没有成功,我仍然得到同样的错误。
当我检查文件 "mail.log "时,我看到以下内容。
Jul 18 08:24:41 company imapd: LOGIN, user=user_name@domain.com, ip=[::ffff:111.111.11.11], protocol=IMAP
Jul 18 08:24:42 company imapd: DISCONNECTED, user=user_name@domain.com, ip=[::ffff:111.111.11.11], headers=0, body=0, rcvd=83, sent=409, time=1
Jul 18 08:25:19 company postfix/smtpd[29282]: connect from company.university.edu[111.111.11.11]
Jul 18 08:25:19 company postfix/smtpd[29282]: NOQUEUE: reject: RCPT from company.university.edu[111.111.11.11]: 554 5.7.1 <email@gmail.com>: Relay access denied; from=<user_name@domain.com> to=<email@gmail.com> proto=ESMTP helo=<UserPC>
Jul 18 08:25:19 company postfix/smtpd[29282]: disconnect from company.university.edu[111.111.11.11]
Jul 18 08:25:22 company imapd: DISCONNECTED, user=user_name@domain.com, ip=[::ffff:111.111.11.11], headers=13, body=142579, rcvd=3289, sent=215892, time=79
文件main.cf
看起来像这样:
#
# Postfix MTA Manager Main Configuration File;
#
# Please do NOT edit this file manually;
#
#
# Postfix directory settings; These are critical for normal Postfix MTA functionallity;
#
command_directory = /usr/sbin
daemon_directory = /usr/lib/postfix
program_directory = /usr/lib/postfix
#
# Some common configuration parameters;
#
inet_interfaces = all
mynetworks = 127.0.0.0/8
mynetworks_style = host
myhostname = mail.domain.com
mydomain = domain.com
myorigin = $mydomain
smtpd_banner = $myhostname ESMTP 2.4.7.1 (Debian/GNU)
setgid_group = postdrop
#
# Receiving messages parameters;
#
mydestination = localhost, company
append_dot_mydomain = no
append_at_myorigin = yes
transport_maps = mysql:/etc/postfix/transport.cf
#
# Delivering local messages parameters;
#
mail_spool_directory = /var/spool/mail
mailbox_size_limit = 0
mailbox_command = procmail -a "$EXTENSION"
biff = no
alias_database = hash:/etc/aliases
local_recipient_maps =
#
# Delivering virtual messages parameters;
#
virtual_mailbox_maps=mysql:/etc/postfix/mysql_virt.cf
virtual_uid_maps=mysql:/etc/postfix/uids.cf
virtual_gid_maps=mysql:/etc/postfix/gids.cf
virtual_mailbox_base=/usr/local/virtual
virtual_maps=mysql:/etc/postfix/virtual.cf
virtual_mailbox_domains=mysql:/etc/postfix/virtual_domains.cf
#
# SASL paramters;
#
smtp_use_tls = yes
smtpd_use_tls = yes
smtpd_tls_auth_only = yes
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtp_tls_CAfile = /etc/postfix/ssl/smptd.pem
smtp_tls_cert_file = /etc/postfix/ssl/smptd.crt
smtp_tls_key_file = /etc/postfix/ssl/smptd.key
smtpd_tls_CAfile = /etc/postfix/ssl/smptd.pem
smtpd_tls_cert_file = /etc/postfix/ssl/smptd.crt
smtpd_tls_key_file = /etc/postfix/ssl/smptd.key
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain =
broken_sasl_auth_clients = yes
smtpd_sender_restrictions =
permit_sasl_authenticated
permit_mynetworks
smtpd_recipient_restrictions =
permit_sasl_authenticated
check_recipient_access hash:/etc/postfix/filtered_domains
permit_mynetworks
reject_unauth_destination
顺便提一下,我的雇主希望能够从我们的本地网络和外部的客户端(Thunderbird和Outlook)发送电子邮件。
54
3
TLS只是对smtp会话进行加密,并不直接影响Postfix是否被允许转发信息。
中继被拒绝的消息发生是因为smtpd_recipient_restrictions规则不匹配。 必须满足其中一个条件,才能让邮件通过:
来解释这些规则:
允许通过SASL认证的发送者。 这对于认证你的网络以外的用户是必要的,这些用户通常是被阻止的。
这将导致postfix在/etc/postfix/filtered_domains中寻找基于收件人地址的规则。 (从文件名上看,它可能只是屏蔽了特定的域名......检查一下gmail.com是否被列在其中?)
这将通过IP地址允许符合$mynetworks中指定的IP范围的主机。 在你发布的main.cf中,$mynetworks被设置为127.0.0.1,所以它将只转发服务器本身产生的邮件。
基于这种配置,你的邮件客户端需要使用SMTP认证才能被允许转发邮件。 我不确定SASL使用的是什么数据库。 这是在/usr/lib/sasl2/smtpd.conf中指定的。据推测,它也使用与你的虚拟邮箱相同的数据库,所以你应该能够在你的邮件客户端中启用SMTP认证,并做好一切准备。
你已经禁用了TLS,所以你现在需要将你的本地网络添加到
mynetworks
中进行授权。比如说、这将固定只从你的本地网络发送。对于从本地网络以外的地方发送邮件,你需要让TLS认证发挥作用。
我认为你在mydestination中漏掉了domain.com,因为默认的
relay_domains=$mydestination
,所以你可以在配置中添加这一行:或:
每次编辑postfix配置文件时,不要忘记重新启动postfix服务器(
service postfix restart
)。