使用 Sieve 检查电子邮件附件

问题描述 投票:0回答:1

我正在尝试自动检测带有附件的电子邮件并将其复制到特定文件夹。我的 Roundcubemail + Sieve 设置有效,可以成功过滤电子邮件并对其采取行动。

但是,我似乎不知道如何检测附件的存在。在带有附件的电子邮件来源中,通常可以找到此部分:

----=_NextPart_...
Content-Disposition: attachment; filename="..." 

因此,我尝试为主体创建一个过滤器,该过滤器对包含单词

attachment
的主体做出反应,作为最小测试用例。但是,当我发送带有附件的电子邮件时,过滤器不会触发。

如果我为标题

Content-Disposition
创建一个过滤器,其中应包含单词
attachment
,也会发生同样的情况。我的猜测是,
Dovecot Managesieve
插件不会过滤电子邮件的整个来源,因此它永远不会遇到上述部分,无论是在正文中还是在标题中。或者,Roundcubemail 以与 Sieve 处理方式不同的方式向我呈现电子邮件源,因此我正在寻找错误的模式。

有谁知道可以检测附件的 Sieve 脚本,或者使用 Roundcubemail 实现我想要做的事情的不同方法?

email filter email-attachments roundcube sieve-language
1个回答
0
投票

您是否尝试过

:mime
测试
:anychild

require "fileinto";
require "mime";

if header :mime :anychild :param "filename" :matches "Content-Disposition" "*" {
    fileinto "INBOX.Attachments";
}
© www.soinside.com 2019 - 2024. All rights reserved.