过滤时考虑邮件标题的顺序

过滤时考虑邮件标题的顺序

我的收件服务器正在检查 SPF,并相应地在标题中添加一行。但是,有时以前的服务器会添加类似的标题,因此会有多个 Received-SPF 标题。

Received-SPF: Softfail...
Received: from ...
Received: by ...
Sender: ...
Received: by ...
Received: by ...
Received: by ...
Received: by ...
Received-SPF: pass ...
Received: by ...

我有一个 procmail 过滤器,可以根据 SPF 状态对收到的邮件进行排序,但它目前无法解释邮件在标题中出现的位置。

我可以制定规则来考虑标题中行出现的位置吗?或者有其他适合此目的的工具吗?

有没有办法区分传入服务器在第一个(最后添加的)接收标头上方添加的标头和另一个服务器添加的标头。

答案1

Procmail 可以进行多行匹配。与许多其他正则表达式变体不同,在 Procmail 中,嵌入$代表两行之间的换行符。如何准确识别正确的Received-SPF:标头显然取决于您的网络拓扑,但类似

:0
* ^Received-spf: pass.*$Received: from .* by yourgateway
... whatever

... 假设您的入站 MX(此处为yourgateway)首先添加Received标头,然后在其前面添加Received-SPF。也可能是相反的情况;如果没有示例标头,我们就无法知道。这两者之间还可能存在其他标头,但这可能是我们可以忽略的。

相关内容