On 16.02.2018 04:36, @lbutlr wrote:
Before I spend a lot of time trying to replicate a procmail script that automatically sorts list mail into mailboxes based on the List-ID header (and possibly some other data) I thought I'd check if someone had already done this for sieve.
Basically, what I do now in procmail is
Get the listname from the List-ID header (or List-post/List-owner if no ID)
check against a list of list-ids and if the ID is not on the list, send it to spamc and put the message (if not spam) in the INBOX but mark it as seen, otherwise put it in Junk.
have some list specific rules (like rewriting reply-to, stripping subjected tags, etc.
Drop message in mailbox based no the ID.
(so, dovecot mail goes into .dovecot/new but RandomFakelist gets scanned for spam and if it passes, marked read and put in the inbox).
I've seen things like:
if exists "List-Id" { if header :contains "List-Id" "dovecot.dovecot.org" { fileinto "dovecot"; } elsif header :contains "List-Id" "others-list.example.com" { fileinto "other-list"; }
But I am looking for something more generic, along the lines of
$myLists = {"dovecot", "postfix", "other-list") if header :contains "List-ID" "<([^\.])+." { $myID $1; } if $myList :contains $myID { if { $myID is other-list { set $myID to Olist; set header "reply-to" to "moderator@users+other@foo.example.net"; } fileinto $myID;
} else { send message to spamc and await results; if spam {fileinto "Junk";} else {fileinto "INBOX";}
(obviously that's not the code, but it should give an idea of the sorts of things I want to do and would rather not entirely duplicate.
Obviously, I don't know if sieve does variables at all (none of the few example scripts I've looked at have them, but then again most procamil scripts don't have them either).
Does sieve support that sort of matching?
Hi!
you can use regular expressions with sieve, see https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples
Aki