在 Fedora 24 上运行 Sendmail 版本 8.15.2 时,大量垃圾邮件来自 (子域).(manydomains).us。我想添加一个过滤器,例如访问文件中可用的内容,以阻止具有子域的 .us TLD。例如:mail.us ---> OK everything.mail.us ---> REJECT
正则表达式可能类似于以下之一:
[a-zA-Z_0-9.-]+@[a-zA-Z_0-9-]+?\.+[a-zA-Z_0-9.-]+?\.(us)$
或者
|(.*\d.*\.us$)
sendmail.mc 文件中有这个位置吗?我认为正则表达式在访问文件中不起作用。 SpamAssassin 和 RBL(例如 Spamhaus)应该开始捕获这些内容,但这里是来自误报的示例:
Return-Path: <[email protected]>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on
ourdomain
X-Spam-Level: ***
X-Spam-Status: No, score=3.1 required=5.0 tests=BAYES_00,FROM_WORDY,
HTML_FONT_LOW_CONTRAST,HTML_MESSAGE,RDNS_NONE,SPF_HELO_PASS,SPF_PASS,
T_HTML_TAG_BALANCE_CENTER,T_REMOTE_IMAGE,URIBL_BLACK autolearn=no
autolearn_force=no version=3.4.1
答案1
我得到了它!请注意,sendmail.mc 文件中的正则表达式之前似乎需要缩进,并且 LOCAL_CONFIG 之前需要额外的行空间。对此的帽子提示XIITEC 博客文章寻找一些线索以及发送邮件食谱。
LOCAL_CONFIG
# this will block subdomain.domain.us or subdomain.domain.info but not domain.us or domain.info
Kcheckaddress regex -a@MATCH
[a-zA-Z_0-9.-]+<@[a-zA-Z_0-9-]+?\.+[a-zA-Z_0-9.-]+?\.(us|info)
HMessage-Id: $>CheckMessageId
SCheckMessageId
R< $+ @ $+ > $@ OK
R$* $#error $: "553 Header error"
LOCAL_RULESETS
SLocal_check_mail
R$* $: $>Parse0 $>3 $1
R$+ $: $(checkaddress $1 $)
R@MATCH $#error $: "553 Your Domain is Blocked for Unsolicited Mail"
这是它有效的证明:
sendmail -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
> Local_check_mail [email protected]
Local_check_mail input: 123 @ aol . com
canonify input: 123 @ aol . com
Canonify2 input: 123 < @ aol . com >
Canonify2 returns: 123 < @ aol . com . >
canonify returns: 123 < @ aol . com . >
Parse0 input: 123 < @ aol . com . >
Parse0 returns: 123 < @ aol . com . >
Local_check_mail returns: 123 < @ aol . com . >
> Local_check_mail [email protected]
Local_check_mail input: 123 @ aol . com . us
canonify input: 123 @ aol . com . us
Canonify2 input: 123 < @ aol . com . us >
Canonify2 returns: 123 < @ aol . com . us >
canonify returns: 123 < @ aol . com . us >
Parse0 input: 123 < @ aol . com . us >
Parse0 returns: 123 < @ aol . com . us >
Local_check_mail returns: $# error $: "553 Your Domain is Blocked for Unsolicited Mail"