如果在From标头中的友好名称匹配子string,Exim ACL将被删除

我收到一个特别可怕的垃圾邮件types,可以通过From标题中的纯文本名称轻松识别。

基本上这个格式是这样的:

From: "foo" <[email protected]> 

我想写一个ACL数据条件,检查foo是否在From头。 你会怎么做?

我相信它会进入DATA ACL部分。

根据标题字段有条件地丢弃邮件:

exim.conf

 system_filter = /etc/exim/system_filter.conf 

system_filter.conf

 if $header_from matches "foo.*<" or $header_from contains "@morespam.com" or $h_subject contains "Viagra" then seen finish endif 

第一个条件只有在foo出现在From头的友好部分时才匹配。 正则expression式不区分大小写。

进行任何更改后最好testingfilter文件。 system_filter.conf语法错误会使传入的消息暂时无法传送。

testing

 exim -bF /etc/exim/system_filter.conf <spam.eml 

spam.eml

 Subject: This is Spam Viagra From: Fred Foo Jones <[email protected]> To: John Smith <[email protected]> Date: Mon, 22 Aug 2016 07:26:20 -0500 This is the body of the e-mail. 

testing会告诉你,如果消息将被传送,丢弃(“完成”),或者如果在filter文件中有错误(在filter文件的Filter error: unknown filtering command "asldkf" near line 75 of filter file得到类似如下的消息Filter error: unknown filtering command "asldkf" near line 75 of filter file


不是一个ACL解决scheme,但我很容易维护。 当条件改变时,我只需要更新system_filter.conf。

我将system_filter放置在exim.conf文件(主要configuration设置)的顶部。 seen finish黑洞命令; 它指示exim已经完成处理消息。

参考: Eximfilter文件

我认为Jim U的回答可能是实现我的目标的一个更好的方法,但为了logging,我在Data ACL中做了如下工作:

 acl_check_data: # Blacklist if friendly name matches any patterns. drop condition = ${if match{$h_from:}{"foo"}} message = Blacklisted. log_message = Blacklisted nasty. 

这导致了一个550 Blacklisted. 错误的SMTP客户端,并立即closures连接。