procmail
[Top] [All Lists]

Re: uuencoding before automatic send

1996-04-04 05:05:02
Thanks for all the help. I should have put the query in
context, I build the header befoe uuencoding.  The solution
below works:

:0
* ^Subject: send file [0-9a-z]
* !^X-Loop: $WORK_ADDR
* !^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

  # 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
}

If anyone can improve this please say so.

Also does anyone have a script that automatically decodes
emails?

-----------------------------------------------------------------------

Marc Rackett wrote,

| I was very interested to see Philip Guenther's reply to 
| D. Emilio Grimaldo's querey concerning the fileserver
| concept.  I have had it working for a while now, but have
| been unsuccessful in getting binary files sent automatically,
| ie uuencoding them first.
| 
| My function is thus:
| 
|    :0 ah
|    | cat - ./$FILE 2>&1 | $SENDMAIL -oi -t
| 
| which is OK if $FILE is ASCII, how can I handle it if is binary?
| 
| I thought something like:
| 
|    :0 ah
|    | cat - ./$FILE 2>&1 | uuencode $FILE | $SENDMAIL -oi -t
| 
| But that does not appear to work, any help would be appreciated.

As Doug Hughes said, you're uuencoding the header and feeding sendmail the
uuencode.  What you want to do is uuencode only the body -- not the original
body, but the new body that consists of the requested file (or keep the file
to send out in uuencoded form in the first place, as Doug suggested; the
extra space that takes up may be less of a problem than freshly uuencoding
it again every time it is fetched).

Try something like this:

   :0abfi #replace body with uuencode
   | uuencode ./$FILE $FILE
    :0a # -oi not needed in newer procmails
    ! -t

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