procmail
[Top] [All Lists]

Re: auto file sending

1997-06-23 16:28:00
dank <dan(_at_)edg(_dot_)sequoias(_dot_)com> writes:

I'm messing with procmail and doing some experimenting with an automatic
fileserver. I used some of the examples from "man procmailex" in the
fileserver section. It works pretty well but the binary file gets put into
the mail but not as a binary attachment. I tried to put in mimencode to
encode the binary file but haven't gotten it to work. here is what i have:

:0
* ^Subject: send file [0-9a-z]
* !^X-Loop: yourname(_at_)your(_dot_)main(_dot_)mail(_dot_)address
* !^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: yourname(_at_)your(_dot_)main(_dot_)mail(_dot_)address"

FILE="$MATCH"            # the requested filename

Looks good with one exception.  You should replace *both* of the
        yourname(_at_)your(_dot_)main(_dot_)mail(_dot_)address
chunks with
        dan(_at_)edg(_dot_)sequoias(_dot_)com
or whatever.

Oh, and the doublequotes around $MATCH are unnecessary.


:0 fbw
| mimencode -b ./$FILE 2>&1 | $SENDMAIL -oi -t
}

This is problem part.

1) This action isn't a filter, so you shouldn't have the 'f' flag.
2) You're not using the reply header you generated above, so sendmail
        doesn't know where to send the message.

You could replace the above problem recipe with:

        :0 hw
        | (cat - ; mimencode -b ./$FILE 2>&1) | $SENDMAIL -oi -t


Or you could compact it all down into this single recipe:

        # Do the filename capture up here
        :0
        *   ^Subject: send file \/[0-9a-z][^ ]*
        * ! ^X-Loop: dan(_at_)edg(_dot_)sequoias(_dot_)com
        * ! ^Subject:.*Re:
        * ! ^FROM_DAEMON
        * ! ^Subject: send file .*[/.]\.
        {
            MAILDIR=$HOME/fileserver # chdir to the fileserver directory

            # "One fell swoop"
            :0 hw
            | ( formail -rA"X-Loop: dan(_at_)edg(_dot_)sequoias(_dot_)com" ; \
                mimencode -b ./$MATCH 2>&1 \
              ) | $SENDMAIL -oi -t
        }


Do you understand how that works?


Philip Guenther

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