筛选脚本不适用于 TLD

筛选脚本不适用于 TLD

我有以下 Sieve 脚本,该脚本用于丢弃或拒绝来自以下域名的任何电子邮件:xxx@xxx.xyz或者 ...。顶部。但是这不是丢弃它们吗?

require ["reject"];

if address :matches :domain "from" ["*chencoin.com", "*.guru", "*.icu", "*.casa", "*.monster", "*.cyou", "*.top", "*.fun", "*.xyz"] {
    #reject "Not allowed.";
    discard;
}

答案1

想知道这是否是完整的 Sieve 脚本会很有趣。我怀疑它不是,并且随后会执行其他fileinto(或keep)操作,将邮件保存到不同的文件夹中。

所做discard的就是取消隐含的保留, 所以如果其他fileinto行动随之而来,它们将会发生。

如果它是完整的脚本,这应该可以工作:

if address :matches :domain "from" ["*chencoin.com", "*.guru", "*.icu", "*.casa", "*.monster", "*.cyou", "*.top", "*.fun", "*.xyz"] {
    discard;
}
# end of script
# (implicit keep happens if no discard was issued.)

这会不是如您所料丢弃:

if address :matches :domain "from" ["*chencoin.com", "*.guru", "*.icu", "*.casa", "*.monster", "*.cyou", "*.top", "*.fun", "*.xyz"] {
    discard;
}

fileinto "INBOX";
# end of script

我建议使用显式方法discard; stop;来防止这种情况:

if address :matches :domain "from" ["*chencoin.com", "*.guru", "*.icu", "*.casa", "*.monster", "*.cyou", "*.top", "*.fun", "*.xyz"] {
    discard; stop;  # <- Note the extra "stop;" here
}

# ... more rules and actions ...

# end of script

另一种方法是将所有内容都放在一个if/elsif/elsif/...逻辑中,这样邮件就不会触及任何会导致的其它规则fileinto

(我认为这种行为是让 Sieve 有点令人沮丧的原因之一。)

相关内容