You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Proton Mail的Sieve过滤器为何在To字段含指定域名时不触发?

问题:Proton Mail Sieve过滤器未匹配含@example.org的邮件

我在Proton Mail中配置了以下Sieve过滤器:

require ["include", "environment", "variables", "relational", "comparator-i;ascii-numeric", "spamtest"];
require ["fileinto", "imap4flags"];

# Generated: Do not run this script on spam messages
if allof (environment :matches "vnd.proton.spam-threshold" "*", spamtest :value "ge" :comparator "i;ascii-numeric" "${1}") {
    return;
}

/**
 * @type or
 * @comparator contains
 * @comparator contains
 */
if anyof (address :all :comparator "i;unicode-casemap" :contains "From" "@example.org", address :all :comparator "i;unicode-casemap" :contains ["To", "Cc", "Bcc"] "@example.org") {
    fileinto "My filter";
}

预期行为:当邮件的From字段,或To/Cc/Bcc字段包含@example.org时,将邮件移入「My filter」文件夹。

大部分邮件可正常匹配,但以下两封邮件未被正确移动:

示例1邮件头

Return-Path: <info-return-490-myaddress=protonmail.com@example.org>
X-Original-To: myaddress@protonmail.com
Delivered-To: myaddress@protonmail.com
Authentication-Results: mail.protonmail.ch; spf=pass smtp.mailfrom=example.org
Mailing-List: contact info-help@example.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Post: <mailto:info@example.org>
List-Help: <mailto:info-help@example.org>
List-Unsubscribe: <mailto:info-unsubscribe@example.org>
List-Subscribe: <mailto:info-subscribe@example.org>
Reply-To: info@example.org
From: John Doe <johndoe@foo.com>
Date: Mon, 27 May 2024 21:35:04 +0200
To: info@example.org
Content-Type: text/html
X-Spam-Rating: mxdhbe07.ad.aruba.it 1.6.2 0/1000/N
Subject: Re: [Gruppo info] Re: gruppo info

示例2邮件头

From: John Doe <myaddress@protonmail.com>
Date: Thu, 30 May 2024 06:07:31 +0000
Mime-Version: 1.0
Content-Type: text/html
To: info@example.org <info@example.org>

上述邮件的To字段明确包含@example.org,但过滤器未触发,请问原因是什么?


原因分析与解决方案

示例1未触发的原因

你的脚本开头包含垃圾邮件判断逻辑:如果邮件的垃圾评分达到Proton的阈值,会直接return终止脚本执行。示例1的邮件带有Precedence: bulk标记,Proton Mail默认会将这类批量邮件归类为垃圾或促销邮件,内部的spamtest评分可能已达到阈值,导致脚本提前退出,后续过滤规则未被执行。

示例2未触发的原因

Proton Mail的Sieve过滤器默认仅对接收的邮件生效,你自己发送的邮件(存储在「已发送」文件夹)不会触发Sieve过滤规则,因此即使To字段符合条件,过滤器也不会执行移动操作。

额外潜在问题::all修饰符误用

你在过滤器中使用了:all修饰符,它的作用是要求所有目标字段中的地址(比如To中的多个收件人)都满足匹配条件才会触发规则。如果某封邮件的To字段同时包含@example.org和其他域名的地址,:all会导致规则不触发——而你实际需要的是只要有一个地址符合条件就触发,此时应该改用:any修饰符(或直接省略,因为:any是默认行为)。


对应解决方案

  1. 处理批量邮件过滤
    若希望批量邮件也能被过滤,可修改开头的垃圾邮件判断逻辑,添加批量邮件例外:

    # 先判断是否为批量邮件,是则跳过垃圾检查
    if header :contains "Precedence" "bulk" {
        # 继续执行后续过滤
    } else {
        # 原有垃圾邮件判断逻辑
        if allof (environment :matches "vnd.proton.spam-threshold" "*", spamtest :value "ge" :comparator "i;ascii-numeric" "${1}") {
            return;
        }
    }
    

    也可直接在Proton Mail的垃圾邮件设置中,将批量邮件标记为非垃圾。

  2. 修正:all修饰符
    将过滤器中的:all替换为:any(或省略),确保单个地址符合条件就触发规则:

    if anyof (
        address :comparator "i;unicode-casemap" :contains "From" "@example.org",
        address :comparator "i;unicode-casemap" :contains ["To", "Cc", "Bcc"] "@example.org"
    ) {
        fileinto "My filter";
    }
    
  3. 处理已发送邮件过滤
    Proton Mail目前不支持通过Sieve过滤已发送邮件,若需此类操作,可手动移动邮件,或使用邮件客户端规则实现。


内容的提问来源于stack exchange,提问作者Mark

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 03:29:52