Am 02.09.2016 um 11:01 schrieb Alessandro Vesely: >> If you would like to sort mails from this mailing list into defined >> folder, then use List-Id header as selection criterium: >> >> if (/^List-Id:.*courier-users.lists.sourceforge.net/) >> to "$HOME/Maildir/$FOLDER/" >> >> (use desired folder name instead on $FOLDER, I use - for this list - >> .Software.Courier.courier-users). > > An obvious generalization, to avoid editing $HOME/.mailfilter on every new > subscription: > > if (/^List-ID:[^<]*<([-_A-Za-z0-9]*)/) > { > DEST=`sed -nr 's/^INBOX(\\.'"$MATCH1"')$/\\1/ip' > ./Maildir/courierimapsubscribed` > if ("$DEST") > { > `test -d "./Maildir/$DEST"` > if ($RETURNCODE == 0) > to "./Maildir/$DEST"; > } > } >
Below is how I did it. Unfortunately the script stopped working a few months ago writing hundreds of mails to (mbox?-)files with useful names like ".@". My debug version with some extra logging needs more input, so I'll send it to this list... ["Yo dawg, I heard you like mail filters..."] Anyway, it's meant to make everything maintenance free. When the first mail from a list you subscribed to is received, a maildir ".listname@some_domain_tld" is created and added to courierimapsubscribed. # Check X-BeenThere which every good list server sets. # List-ID is okay, too. if ( /^X-BeenThere:\s+(.*)@(.*)/ ) { # Pick local part and domain part, replace the dots with # underscores. ### BUG: This leaves LPART and DPART empty. :( ### LPART=`echo $MATCH1 | sed "s/\./_/g"` DPART=`echo $MATCH2 | sed "s/\./_/g"` PREFIX="" FOLDER=".$LPART@$DPART" # I want subfolders for organizations with more than one list: if ( /^X-BeenThere:.*specialorg.*/ ) { PREFIX=".specialorg" FOLDER=".$LPART" } NEWDIR=$HOME/Maildir/$PREFIX$FOLDER # create the maildir if it doesn't exist: `test -d "$NEWDIR"` if( $RETURNCODE == 1 ) { `maildirmake $NEWDIR` `echo "INBOX$PREFIX$FOLDER" \ >> $HOME/Maildir/courierimapsubscribed` } to $NEWDIR } Maybe additional quotation marks are required around "$MATCH[1|2]"? d. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ courier-users mailing list courier-users@lists.sourceforge.net Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users