Note: Updated dec. 16th 2011
Procmail Solution
The following recipe works for me. .Junk - spam folder:
MAILDIR=$HOME/Maildir :0 * ^X-Spam-Flag: YES { # First deliver to maildir so LASTFOLDER gets set :0 c .Junk # Manipulate the filename :0 ai * LASTFOLDER ?? ()\/[^/]+^^ |mv "$LASTFOLDER" "$MAILDIR/.Junk/cur/$MATCH:2,S" }
Maildrop Solution
Foreword: Recently, I (no, I wanted to) do the same with maildropfilter. After reading man maildropfilter I came up with the following recipe. I am sure that people will find this convenient - I know that I know.
In the example below, new e-mail messages are marked as read as well as unread old messages.
SPAMDIRFULL="$DEFAULT/.Junk" if ( /^X-Spam-Flag: YES$/ || \ /^X-Spam-Level: \*\*\*/ || \ /^Subject: \*+SPAM\*/ ) { exception { cc "$SPAMDIRFULL" `for x in ${SPAMDIRFULL}/new/*; do [ -f $x ] && mv $x ${SPAMDIRFULL}/cur/${x##*/}:2,S; done` `for x in ${SPAMDIRFULL}/cur/*:2,; do [ -f $x ] && mv $x ${SPAMDIRFULL}/cur/${x##*/}S; done` to "/dev/null" } }
Note that the exception command may be considered invalid. The manual states the following:
The exception statement breaks the errors that maildrop usually causes to complete. If a fatal error occurs anywhere inside a block of statements enclosed in an exception clause, execution will resume immediately after the exception clause.
source share