sieve: is it possible to filter ALL mailing lists (with header List-Id) to their folders with ONE rule?
Hello, Dovecot.
Is it possible to write one rule in sieve, which will:
(1) Trigger on any message with "List-Id" header
AND
(2) Put this message to folder with name build from content of "List-Id" header, in such way, that message with List-Id
List-Id: This is decription of list
will be put into folder "org.host.list-name" where "." is namespace separator (so, such folders will be shown as hierarchy in mail client)?
I don't want to write ~50 rules by hands and add new ones from time to time.
I'm speaking about dovecot/pigeonhole sieve implementation, of course. All examples on net shows only manual one-rule-per-list approach :(
-- // Black Lion AKA Lev Serebryakov lev@serebryakov.spb.ru
Lev Serebryakov:
List-Id: This is decription of list
will be put into folder "org.host.list-name" where "." is namespace separator (so, such folders will be shown as hierarchy in mail client)?
:-) had the same idea while writing my sieve file ...
Another idea would be a key -> value map key : list-id value: foldername
Andreas
Hello list,
just a quick guess from my side:
if header :matches "List-ID" "<*.*.*>" {
fileinto "INBOX.${3}.${2}.${1}"; stop;
}
this should do the trick
-dominik
Am Freitag, den 12.09.2014, 20:37 +0200 schrieb A. Schulze:
Lev Serebryakov:
List-Id: This is decription of list
will be put into folder "org.host.list-name" where "." is namespace separator (so, such folders will be shown as hierarchy in mail client)?
:-) had the same idea while writing my sieve file ...
Another idea would be a key -> value map key : list-id value: foldername
Andreas
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512
On 09/12/2014 23:40, Dominik Breu wrote:
Looks like it should work, only should be tinkered for different number of parts in ID. But it is better than full-manual :)
Thank you.
just a quick guess from my side:
if header :matches "List-ID" "<*.*.*>" { fileinto "INBOX.${3}.${2}.${1}"; stop; }
this should do the trick
-dominik
Am Freitag, den 12.09.2014, 20:37 +0200 schrieb A. Schulze:
Lev Serebryakov:
List-Id: This is decription of list
will be put into folder "org.host.list-name" where "." is namespace separator (so, such folders will be shown as hierarchy in mail client)?
:-) had the same idea while writing my sieve file ...
Another idea would be a key -> value map key : list-id value: foldername
Andreas
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2
iQJ8BAEBCgBmBQJUE04fXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRGOTZEMUNBMEI1RjQzMThCNjc0QjMzMEFF QUIwM0M1OEJGREM0NzhGAAoJEOqwPFi/3EePoHkP/2Q+YYlrBDOlsRcmc4HaeWOV NvbIuWx390deikxaXmD7YiHaE58m1sOzjLzUiySgfV1zA4BoXlD8AyzcSMeNMJz4 hH6XUlRG9iLUt8PikHBNyzoqWR/xEsQK7ELxdKhX7pAk66TG1h+pUj9L11Bmy4wb lkZ2em7HtDudQSg+GYAVEvb3UW79FzEAaWlyyy3qOmDpahGGOIJgQfqN9+m3TNU0 BTHvhI6NQNoodyq4G6VqsrAnO2bOjkbbdKG2lYg/TnfcoW9gy6AinEzVaE9QepO5 qebrRBj1RGfkqvBRm9dAfTtG1qrL7LfCKZFuQBAnwmG6/Wgot/bIWM2S8YGApY9X WfukwzAOmX16YQAmAZB+WGuKw3RFCwvT7NXi5/2xzf+Njzpj1UmVBjPIBCZ6fk85 k3ljYXbmF0deHBkpMpTc7hBFYJcU+nJhPArNQE3jpcVtmk28+k/PZkbLBL1AK9Lu rwBCNYRXVa/k7YtE6g2H9s21tP7lrepVj1YeD8ZyPlfgDZ2cPmFLZJ73hEdoPBCZ YBU7ViQ/zzV/PTtW1T66uz9N+Ex1LfwDI079T0b4kCZuABjq4bCuXKxVqAu52bWW eL4MytN5jjbrJ9jRGrCimhQwZTENBS5JdornOIOH82I/lhEN/Y9TJWRWMYWyR01p LitgYGm4t45cYf1SvA+j =Q7U7 -----END PGP SIGNATURE-----
Am 12.09.2014 um 21:40 schrieb Dominik Breu:
Hello list,
just a quick guess from my side:
if header :matches "List-ID" "<*.*.*>" { fileinto "INBOX.${3}.${2}.${1}"; stop; }
this should do the trick
-dominik
nice i think ,you might need listescape plugin for folders with dots, depend to your namespace setup
Am Freitag, den 12.09.2014, 20:37 +0200 schrieb A. Schulze:
Lev Serebryakov:
List-Id: This is decription of list
will be put into folder "org.host.list-name" where "." is namespace separator (so, such folders will be shown as hierarchy in mail client)?
:-) had the same idea while writing my sieve file ...
Another idea would be a key -> value map key : list-id value: foldername
Andreas
Best Regards MfG Robert Schetterer
-- [*] sys4 AG
http://sys4.de, +49 (89) 30 90 46 64 Franziskanerstraße 15, 81669 München
Sitz der Gesellschaft: München, Amtsgericht München: HRB 199263 Vorstand: Patrick Ben Koetter, Marc Schiffbauer Aufsichtsratsvorsitzender: Florian Kirstein
On Fri, Sep 12, 2014 at 10:25:19PM +0400, Lev Serebryakov wrote:
Hello, Dovecot.
Is it possible to write one rule in sieve, which will:
(1) Trigger on any message with "List-Id" header
AND
(2) Put this message to folder with name build from content of "List-Id" header, in such way, that message with List-Id
List-Id: This is decription of list
will be put into folder "org.host.list-name" where "." is namespace separator (so, such folders will be shown as hierarchy in mail client)?
I don't want to write ~50 rules by hands and add new ones from time to time.
I'm speaking about dovecot/pigeonhole sieve implementation, of course. All examples on net shows only manual one-rule-per-list approach :(
Not one rule, but I use the following script to filter mailing lists into folders. It handles most mailing list types and, for consistency, the folder name is case-folded to title case.
## require [ "regex", "variables", "fileinto", "envelope", "mailbox", "imap4flags" ];
# Mailinglist Killfile if anyof (header :contains "from" "unwanted@example.com", header :contains "from" "spammer@example.net", header :contains "from" "troll@example.org"){ discard; stop; }
if anyof (header :contains "x-spam-flag" "yes", allof (header :regex "X-DSPAM-Result" "^(Spam|Virus|Bl[ao]cklisted)$", not header :contains "X-DSPAM-Reclassified" "Innocent")){ # Spam goes into the spam folder setflag "\\Seen"; fileinto :create "spam"; stop; }
# split out the various list forms # Mailman & other lists using list-id if 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; }
participants (5)
-
A. Schulze
-
Darac Marjal
-
Dominik Breu
-
Lev Serebryakov
-
Robert Schetterer