Here's the recipes I use to allow one of my clients to update his web pages.
Why? It's a long story. Thanks in part to the gentleman who cleared me up on
the correct use of umask.
NL="
"
# the above grossness is how you create a newline character for use in the log
OLDUMASK=$UMASK
# save the current umask
UMASK=022
# set the umask to allow user wr, group r, other r (umask is 3 octal digits
representing the bits you want to clear (negative logic))
:0w:client_A
# :0 = start of recipe
# w = wait for recipe to complete (hopefully this will reduce the occurence of
Error while writing to "x" (see procmail man page))
# :client_A = use client_A as a lockfile in case multiple attachment messages
are received; I doubt this guarantees they are done in order
# the file client_A must not usually exist -- its presence indicates the
lavatory is occupied
* ^TO_client_A(_at_)mydomain(_dot_)com
# * = recipe condition
# search the To: Cc: Bcc: and other fields for the exact address
client_A(_at_)mydomain(_dot_)com
* ? formail -r -xTo: | egrep -iqs
"(okuser1(_at_)somedomain\(_dot_)com|client_A\.com)"
# * = another condition that must also be true (logical AND)
# ? = test the exit code of the following command(s)
# search the From_ field for the only people allowed to use the above address
-- okuser1(_at_)somedomain(_dot_)com or anyone @client_A.com
# why does one use formail to do this? It's a black art. Just accept it
without questioning ;-) Seriously, you will have to read elsewhere
REPORT=| (munpack -C $HOME/client_A_meta ; mv --backup=numbered
$HOME/client_A_meta/* /home/webroot/client_A/docs ; )
# REPORT= = put the result of the following commands into REPORT
# | = pipe the whole message into the following commands
# $HOME/client_A_meta is a staging directory that is only used for receiving
attachments for client_A
# if the message has plain text, it will be called attachment#1filename.desc
I'm too lazy to bother with supressing it.
:0e
# :0 = start of recipe
# e = "else" -- do this recipe only if previous recipe fails
{
# start of block (so I can put an assignment instead of piping the contents of
the message anywhere)
LOG="$NL### client_A: $REPORT$NL"
# write a newline, something that I'll recognize, the contents of REPORT, and
another newline
}
# end of block
UMASK=$OLDUMASK
# restore the original umask
Jeff
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail