后缀:有条件的头检查

这是我的SMTP情况。

邮件stream由在线中继提供商(!! SPAM !!,!! BULK !!等)标记

邮件stream由内部后缀接收。 运输被configuration为中继到我们的内部交换,否则如果主题被标记。 我使用Header_checks来做到这一点。 标记的邮件stream被分派到我们的隔离服务器(webUI为个人用户等…)

/^[sS]ubject:.*!!SPAM!!*/ FILTER smtp:192.168.11.250 /^[sS]ubject:.*!!BULK!!*/ FILTER smtp:192.168.11.250 /^[sS]ubject:.*!!SUSPECT!!*/ FILTER smtp:192.168.11.250 

它工作正常。 我们的隔离服务器可以为用户生成可信发件人列表。 这个白名单是可用的,我可以下载到我的后缀。

我的问题是:如何在标题检查之前应用我的白名单?

  If Subject contains *!!SPAM!!* then If from contains [email protected] AND if to contains [email protected] Then redirect to internal exchange server else redirect to quarantine server endif endif 

我不知道该怎么做。 任何提示?

从@masegaloeh发表评论后,我find了一个解决scheme。 我们的想法是让第二个postfix SMTP服务器在10025上使用策略服务器进行侦听,以便将邮件发送到普通服务器(如果列入白名单)或隔离服务器。

这个想法是从main.cf中的header_checks解决scheme开始的:

 header_checks = regexp:/etc/postfix/header_checks 

在header_checks中:

 /^(S|s)ubject: .*!!(SPAM|BULK|SUSPECT)!!.*/ FILTER smtp:127.0.0.1:10025 

然后在master.cf中(用@masegaloeh注释编辑):

 10025 inet n - n - - smtpd -o receive_override_options=no_header_body_checks -o smtpd_recipient_restrictions=${my_switcher_restrictions} policy unix - nn - 0 spawn user=nobody argv=/etc/postfix/policy-server-switcher 

这使得postfix的第二个实例覆盖了header_checks的使用。

在main.cf中

 my_switcher_restrictions = check_policy_service unix:private/policy 

策略服务器切换器的内容

 !/bin/bash sender="" recipient="" while read line do key=$(echo $line | cut -f1 -d=) value=$(echo $line|cut -f2 -d=) if [ "$key" == "sender" ] then sender=${value} logger -p mail.info -t PolicyServer "Sender is: ${value}" fi if [ "$key" == "recipient" ] then recipient=${value} logger -p mail.info -t PolicyServer "Recipient is: ${value}" fi if [ "x${recipient}" != "x" ] && [ "x${sender}" != "x" ] then if [ "$sender" == "[email protected]" ] && [ "$recipient" == "[email protected]" ] then echo "action=FILTER smtp:192.168.1.150" echo exit 0 fi if [ "$sender" == "[email protected]" ] && [ "$recipient" == "[email protected]" ] then echo "action=FILTER smtp:192.168.1.150" echo exit 0 fi echo "action=FILTER smtp:192.168.1.151" echo exit 0 fi done 

当然,您需要编写策略服务器来从数据库或LDAP加载白名单,这里仅仅是一个例子来说明想法。

但是,这仍然有一些警告,假设我发送一封邮件

来自:[email protected]

致:[email protected]

致:[email protected]

这将转到正常的服务器为alphamikevictor和托马斯,只要对政策服务器的最后一次testing返回到正常,但如果您将alphamikevictor放在第二个位置然后它将发送邮件两个收件人隔离。