procmail
[Top] [All Lists]

Re: Make procmail write to /tmp on home machine?

1997-11-11 11:42:23
Philip Guenther suggested to Andrew Kelley:

| use a cronjob that invokes something like:
| 
|       cd your-maildir && lockfile spam.lock && test -s spam && { procmail 
DEFAULT=/tmp/spam.box /dev/null <spam && rm -f spam; rm -f spam.lock; }
| 
| WARNING: the above assumes the following:
|       everything in your-maildir/spam is spam and belongs in /tmp/spam.box

or likely enough to be spam to sit in /tmp/spam.box until you check it and
unlikely enough to be valuable mail that it's no loss if /tmp is cleaned out
before you read it

|       no further filtering of the messages is necessary: they just need to
|               be moved (it actually treats everything in the
|               your-maildir/spam as a single message and uses procmail as
|               a reliable copy command, thus the DEFAULT assignment as the
|               use of /dev/null as a empty procmailrc)

It also assumes that there is one, and only one, message in the spam folder!
procmail will change the initial "From " of every message after the first to
">From " and concatenate its head and its body to the body of the first
message.

|       /tmp/spam.box is a not a directory

That can be handled, but the digression would be long, so let's stick for now
with the case where $MAILDIR/spam and /tmp/spam.box are both plain folders.

| If the latter two of those conditions isn't true OR IF THEY MIGHT
| CHANGE then you should use formail -s to break the message apart and
| invoke procmail on each one separately.

I don't see why there is any need to call procmail here at all (backslash
and newline added for legibility in this post; most versions of cron need
it all on one long line as Philip illustrated, or one can put it into a
shell script and have cron call the script by name):

cd your-maildir && test -s spam && lockfile spam.lock && \
 { cat spam >> /tmp/spam.box && rm -f spam spam.lock || rm -f spam.lock ; }

<Prev in Thread] Current Thread [Next in Thread>