On 20/02/2021 18:02, Shawn Heisey wrote:
On 2/20/2021 8:50 AM, Markus Schönhaber wrote:
I consider it a better idea to filter mailing list messages by their List-ID header.
I agree with Markus. It's what I do. This works well:
if header :regex "list-id" "solr-user.lucene.apache.org" { fileinto "asf.solr-user"; stop; }
I do not know if List-ID is common to all mailing list software, but even if it's not, there should be something available in the message headers that you can use.
It's not, but it's fairly common. A few years ago someone posted a strategy for procmail that handled almost any kind of mailinglist software. I've translated that to the following sieve script (which, now that I look at it, could probably do with a bit of optimisation):
split out the various list forms
Apparently, mutt-users has some odd format, so handle it specially.
if exists "list-post" { if header :regex "list-post" "<mailto:([a-z_0-9-]+)[.@]" { set :lower "listname" "${1}"; fileinto :create "${listname}"; } else { keep; } }
Mailman & other lists using list-id
elsif exists "list-id" { if header :regex "list-id" "<([a-z_0-9-]+)[.@]" { set :lower "listname" "${1}"; fileinto :create "${listname}"; } else { if header :regex "list-id" "^\\s*<?([a-z_0-9-]+)[.@]" { set :lower "listname" "${1}"; fileinto :create "${listname}"; } else { keep; } } stop; }
Listar and mailman like
elsif exists "x-list-id" { if header :regex "x-list-id" "<([a-z_0-9-]+)\\\\." { set :lower "listname" "${1}"; fileinto :create "${listname}"; } else { keep; } stop; }
Ezmlm
elsif exists "mailing-list" { if header :regex "mailing-list" "([a-z_0-9-]+)@" { set :lower "listname" "${1}"; fileinto :create "${listname}"; } else { keep; } stop; }
York lists service
elsif exists "x-mailing-list" { if header :regex "x-mailing-list" "^\\s*([a-z_0-9-]+)@?" { set :lower "listname" "${1}"; fileinto :create "${listname}"; } else { keep; } stop;}
Smartlist
elsif exists "x-loop" { if header :regex "x-loop" "^\\s*(a-z_0-9-]+)@?" { set :lower "listname" "${1}"; fileinto :create "${listname}"; } else { keep; } stop; }
poorly identified
elsif envelope :contains "from" "owner-" { if envelope :regex "from" "owner-([a-z_0-9-]+)-outgoing@" { set :lower "listname" "${1}"; fileinto :create "${listname}"; } elsif envelope :regex "from" "owner-([a-z_0-9-]+)@" { set :lower "listname" "${1}"; fileinto :create "${listname}"; } elsif header :regex "Sender" "owner-([a-z_0-9-]+)@" { set :lower "listname" "${1}"; fileinto :create "${listname}"; } else { keep; } stop; }
other poorly identified
elsif envelope :contains "from" "-request" { if envelope :regex "from" "([a-z_0-9-]+)-request@" { set :lower "listname" "${1}"; fileinto :create "${listname}"; } else { keep; } stop; }
Thanks, Shawn