Marc Rackett asked,
| The solution below works[.] If anyone can improve this please say so.
| :0
| * ^Subject: send file [0-9a-z]
| * !^X-Loop: $WORK_ADDR
That condition needs the $ modifier to get the variable expanded. Otherwise
procmail will take it as a newline followed by the literal text "WORK_ADDR",
and you won't get any loop detection.
| * !^Subject:.*Re:
| * !^FROM_DAEMON
| * !^Subject: send file .*[/.]\.
| {
| MAILDIR=$HOME/fileserver # chdir to the fileserver directory
|
| :0 fhw # reverse mailheader and extract name
| * ^Subject: send file \/[^ ]*
| | formail -rA "X-Loop: $WORK_ADDR"
|
| FILE="$MATCH" # the requested filename
|
| :0 ah
| | (cat - ; uuencode ./$FILE $FILE 2>&1) | $SENDMAIL -oi -t
And there you've fixed it: you're uuencoding only the file, not the header.
It's not as efficient as the way I suggested (you're running cat, uuencode,
sendmail, and a shell instead of just uuencode and sendmail), but it works
and you're happy with it, so let's leave that part alone.
| # If we got here, than something bogus happened, like a request to
| # "send file *" (If wildcards are okay on the send file side, then
| # add them to the set in the proper line.) Otherwise, this is a
| # "cannot happen" situation.
| :0 fb
| | (echo "MAIL FILESERVER FATAL ERROR!"; echo ""; cat -)
|
| :0:
| $DEFAULT
| }