procmail
[Top] [All Lists]

Re: Send list to incoming folder

1997-12-08 07:24:16
Sun 97-12-07 david hunt <dh(_at_)west(_dot_)net> list.procmail
| For other examples my current .procmailrc and .forward files can be viewed
| at:   http://www.west.net/~dh/homedir/pmdir/

David, you have interesting recipe in your .procmailrc.
Would you care to explain how the sorting works, i'm now sure
I undertood the idea.

jari


# Sort mail in mbx: When sent a mail by a script, procmail dumps the mbx
# to a tmpfile, then pipes the tmpfile back through formail and procmail
# recursively. This perversity accomplishes the sorting of the mbx by a
# cmnd:         ":|formail +0 -I"Command: sortmail" -s procmail &'"
# which is aliased to "sortmail". The cmnd causes formail to generate a
# short mail which it hands to procmail. This recipe is triggered by that
# mail, losing the triggering mail, and running the commands in the
# action of the recipe. Reason for the perverse method is that I don't
# have permission to lock my mailbox, but procmail does.
# Note that this adds up to two calls of formail and two calls of procmail.
TMP=$HOME/tmp$$
:0 chiw:$DEFAULT$LOCKEXT
* (^From foo(_at_)bar  [[a-z0-9]+)              
* ^Command: sortmail$
| cp $DEFAULT $TMP \
&& cp /dev/null $DEFAULT \         
|| echo 'Oops! Your mail may be in $DEFAULT and\or $TMP'
:0 aw:$TMP$LOCKEXT
| rm -f $DUPCACHE\
&& cat $TMP|$FORMAIL +0 -I"X-Sortmail: $$" -s $PROCMAIL \             
&& rm $TMP \     
||echo 'Oops! All of your mail may still be in $TMP'