procmail
[Top] [All Lists]

Re: Automativ retrieval of files by reply

1995-10-23 14:16:02
I am setting up a system in which recipients of a mailing list will be
asked to retrieve a file using SmartList. Ideally I would like to be
able to send a mail saying 'just reply to this message without editing
the reply' in order to allow the users to easily retrieve the file
concerned. This would require some playing with the keywords used to
trigger sendmail - e.g. being able to cope with a subject line of 

      Subject: Re: archive get foo.bar

as well as allowing correct reply addresses.

Has anyone else actually done this?

Thanks,

You do not need to bother sendmail about this, except possibly to use an
alias.

You could even set this up using your own, personal address.  Since
seeing is believing, send me an email with the subject: "send help"
(without the quotes).

Or, instead of using your own address, you could create an alias, with a
procmail recipe as the target of the recipe, using the '-m' option.

Here's an example of how to do this:

/usr/lib/aliases:
    
    archive: "|/usr/local/bin/procmail -m /etc/procmailrcs/archive"
    archive-owner: nils

Set the ownership of "archive" to be the login which has proper read
access to the archive files.

The procmail recipe can be something like this:

/etc/procmailrcs/archive:

    # Set MAILDIR to where you wish the filter to operate out of
    MAILDIR=/usr/local/archivedir

    ARCHIVELOG=archive.log

    # **** Untested ****
    :0
    * ^Subject: *(Re: *)?archive *get *\/([^ ]+\)
    * !^X-Loop: archive(_at_)$HOST
    {
        FILE=$MATCH
        FROM=`formail -rtzx'From:'`

        # Keep a log of archive commands
        :0 cw:$ARCHIVELOG.lock
        | echo "`date` : $FROM : get $FILE" >> $ARCHIVELOG

        # form a reply header
        :0 fhw
        | formail -rt -I"From: Archive Daemon <archive>" \
                      -I"Precedence: low" \
                      -I"X-Loop: archive(_at_)$HOST"
                      -I"Subject: results of 'get $FILE'"

        # Set this to the directory in which the files live
        # If a plain name, is relative to $MAILDIR
        FILESDIR=files

        # Make sure the file exists, and put it as the body
        :0 fbw
        * test -f $FILESDIR/$FILE
        | cat $FILESDIR/$FILE

        # Report I/O errors
        :0 efbw
        | echo "Sorry, there is a problem reading $FILE just now."

        # Report when the file is missing
        :0 Efbw
        | echo "Sorry, $FILE is not currently available.  Try again later."

        # Now, send the results to the reply address
        :0 w
        ! -oi -t
        # If sendmail fails, the mail will get sent to archive-owner, below
    }

    # Send unusual or looping mail to the archive owner
    ! archive-owner

<Prev in Thread] Current Thread [Next in Thread>
  • Re: Automativ retrieval of files by reply, Alan Stebbens <=