我订阅了一个邮件列表,但通过该列表发送的邮件主题中没有表明其身份。
我希望将列表邮件发送到我的主收件箱,但仍然能够一眼就识别出这些邮件来自该列表。
我的 MTA(Dovecot)支持大多数 Sieve 过滤器通常的扩展。
我如何才能在该列表的邮件前面添加“[Foo-List]”标签?
答案1
似乎没有标准化的方法可以直接在邮件的主题头前面添加或附加字符串,但可以使用editheaders
和variables
扩展来解决这个问题:
require "editheader";
require "variables";
# Match/select your message as you see fit
if header :contains "List-Id" ["<foo.lists.example.net>"]
{
# Match the entire subject ...
if header :matches "Subject" "*" {
# ... to get it in a match group that can then be stored in a variable:
set "subject" "${1}";
}
# We can't "replace" a header, but we can delete (all instances of) it and
# re-add (a single instance of) it:
deleteheader "Subject";
# Append/prepend as you see fit
addheader :last "Subject" "[Foo-List] ${subject}";
# Note that the header is added ":last" (so it won't appear before possible
# "Received" headers).
}