我訂閱了一個郵件列表,但該列表在透過該列表發送的郵件的主題中並未表明自己的身份。
我希望將清單郵件發送到我的主收件匣,但第一眼仍然能夠識別它們是來自清單的。
我的 MTA (Dovecot) 支援大多數篩式過濾器常用擴充名。
如何在此清單中的郵件前面新增「[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).
}