如何在Postfix中阻止电子邮件地址?

我需要阻止在postfix发送电子邮件的外部电子邮件地址。 这是我不控制的第三方域名的外部电子邮件地址。

我需要阻止它的原因是因为他们有一些错误的configuration,我每秒钟都会收到一条消息:“警告,您的消息还没有被发送”。 我已经联系了他们的技术支持,但他们花了很长时间来修复它,同时,我的服务器和我的用户正在受苦。

我试过这样做。 在我的mail.cf我补充说:

smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_access, permit 

并在/ etc / postfix / sender_access中添加:

 [email protected] REJECT 

我跑

 postmap hash:sender_access 

并重新启动后缀,但似乎没有效果。

我也试过:

 smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/sender_access 

在main.cf中,这个错误会失败:

 postfix/smtpd[2144]: fatal: parameter "smtpd_recipient_restrictions": specify at least one working instance of: check_relay_domains, reject_unauth_destination, reject, defer or defer_if_permit 

试:

 smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/sender_access, permit 

给了我同样的错误。

check_sender_access应该在reject_unauth_destination之后,或者你可以成为一个开放的中继。

 smtpd_recipient_restrictions = reject_unauth_destination, check_sender_access hash:/etc/postfix/sender_access 

请参阅: http : //www.postfix.org/postconf.5.html#smtpd_recipient_restrictions

重要:smtpd_relay_restrictions或smtpd_recipient_restrictions参数必须至less指定以下限制之一。 否则Postfix将拒绝接收邮件:

拒绝,reject_unauth_destination

推迟,延迟_if_permit,defer_unauth_destination

另一方面,使用smtpd_sender_restrictions应该工作,所以你可能有其他东西之前接受电子邮件。

正如Laurentio Roescu所说, smtpd_sender_restrictions 应该可以工作。 只有我不认为这是什么意图。 发件人是从您的服务器发送电子邮件的人。 不是来自另一边的发件人。

所以你确实想要使用smtpd_recipient_restrictions = check_sender_access ... ,但是正如文档中提到的那样,如果你使用它,这个被smtpd_relay_restrictions覆盖。

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

Postfix SMTP服务器在客户端RCPT TO命令的上下文中应用smtpd_relay_restrictions之后的可选限制。 有关评估上下文和时间的讨论,请参阅SMTPD_ACCESS_README中的“延迟评估SMTP访问限制列表”一节。

在2.10之前的Postfix版本中,中继权限和垃圾邮件阻止的规则被合并在smtpd_recipient_restrictions下,导致容易出错的configuration。 从Postfix 2.10开始,中继权限规则最好使用smtpd_relay_restrictions来实现,这样smtpd_recipient_restrictions下的允许垃圾邮件阻止策略将不再导致允许的邮件中继策略。

为了向后兼容,在2.10之前从Postfix版本迁移的站点可以将smtpd_relay_restrictions设置为空值,并像以前一样使用smtpd_recipient_restrictions。

所以,你会做:

 smtpd_relay_restrictions = ... ... check_sender_access hash:/etc/postfix/sender_access ... 

这样就应该按照预期来考虑。 (…代表其他选项,请务必将此检查放在列表中的正确位置。)