Procmail: go to the folder and mark as read

simple question: I want to move emails with a specific subject to a folder and mark them as read later. Moving works for me using

:0: H * ^Subject:.*(ThisIsMySubject) $HOME/mail/ThisIsMyFolder 

But how to mark letters as read?

+6
source share
1 answer

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.

+11
source

Source: https://habr.com/ru/post/887269/


All Articles