Postfix 阻止本地域发送

Postfix 阻止本地域发送

我有一台运行 apache 的 centos 6.5 服务器,托管大约 8 个域。还安装了 postfix 2.6,为这些本地域提供服务,以发送由 php(网站联系表单)生成的电子邮件。Postfix 安装是默认安装。没有对 main.cf 或任何其他文件进行任何修改。

现在,其中一个网站已被黑客入侵,并正在使用以下地址发送垃圾邮件:random_user1@hacked_domain.com,random_user2@hacked_domain.com,random_user3@hacked_domain.com(hacked_domain.com 是被黑客入侵网站的实际域名)

我想阻止这个特定(本地)域发送,而其他所有域都可以正常发送。到目前为止,我已经创建了一个“黑名单”,并将其保存在名为“rbl_blacklist”的 postfix 文件夹中,如下所示:

hacked_domain.com    REJECT

我如何在 main.cf 中使用此文件来阻止发送来自 ***@hacked_domain.com 的消息?

(此外,欢迎任何其他建议)

编辑:

我不想屏蔽某些用户,因为根本就没有!我只想屏蔽所有来自 *@hacked_domain.com 的电子邮件!

答案1

解决方案是“header_checks”

在 main.cf 中注释掉任何“header_checks”行 - 如果存在然后添加:

header_checks = pcre:/etc/postfix/header_checks.pcre

创建 header_checks.pcre 文件(在 postfix 文件夹中)

# cd /etc/postfix
# vi header_checks.pcre

在 header_checks.pcre 文件中添加了以下行:

/^From:((?![^@]*?user1|[^@]*?user2|[^@]*?user3|[^@]*?webmaster)[^@]*?)@hacked_domain\.com/ DISCARD

(我们只允许用户 1、用户 2、用户 3 和网站管理员发送电子邮件 - 其他地址被丢弃!)

# service postfix restart

...并且有效!

希望能够帮助其他有类似问题的人!

答案2

我建议的问题中提到的方法可能是这个方法的重复(Postfix 阻止本地用户发送) 可以帮助防止出现问题(如果首先使用单个本地帐户提交这些电子邮件)。

由于您提到了“php(网站联系表单)”,我假设您可能有一个用户在每个域上运行 PHP,并且能够阻止链接到被黑域上的表单的用户提交电子邮件。

但是,如果你确实需要阻止 postfix 从该域发送电子邮件,则可以使用 smptd_sender_restrictions(http://www.postfix.org/postconf.5.html#smtpd_sender_restrictions)——我在链接的问题中也提到了这一点。

具体来说,您可以使用check_sender_access并配置合适的查找表,例如:

 smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/block_spam_access

然后,您可以使用您创建的黑名单来填充/etc/postfix/block_spam_access(或您选择的任何路径),这应该有所帮助。

http://www.postfix.org/access.5.html除了 REJECT 之外的其他选项(DISCARD 可能会有用)。

另一种方法可能是使用传输图,可能使用sender_dependent_relayhost_mapshttp://www.postfix.org/postconf.5.html#sender_dependent_relayhost_maps)。

http://www.postfix.org/transport.5.html对于传输语法-你可能需要类似的东西:hacked_domain.tld error:mail for hacked_domain.tld is not deliverable

相关内容