procmail
[Top] [All Lists]

Re: Help: running a C program when mail arrives

1996-08-13 17:47:37
This 'recipe' correctly MATCHes the email address, but yields an error
of 
procmail: Program failure (255) of "/bin/mail $MATCH </etc/letter

What seems to be happening is that procmail isn't simply triggering the
mail program, but either attempting to pipe the mail message to
/bin/mail, or not passing $MATCH to /bin/mail

Mail is returning a non-zero status for some reason.  You can either
figure out why Mail is returning nonzero, and fix the problem (if there
is one), or wrap the mail invocation within another shell script
which is guaranteed to return status 0 (by doing "exit 0").

Even better, though, is to let procmail send the mail, rather than
have it call a less capable mail delivery program :^).

If you have a piece of mail in /etc/letter (with or without headers)
and want to send it to a user, $MATCH, just do this:

    :0c         # fork a new process, cause we're replacing the mail buffer
    {
        :0f             # place the letter in the mail buffer
        | cat /etc/letter

        # send the mail to the destination
        :0
        ! $MATCH
    }

If there are no headers in /etc/letter, and you wish to have reasonable
ones inserted, do something like this (assume $SUBJECT has been set
appropriately):

    :0c
    {
        :0fb            # replace the body
        | cat /etc/letter

        :0fh
        | formail -I"From:    The Mailer-Daemon <mailer-daemon>" \
                  -I"To:      $MATCH" \
                  -I"Subject: $SUBJECT" \
                  -I"Precedence: urgent"

        :0
        ! $MATCH
    }

G'luck.
_____________________________________________________________________
Alan Stebbens <stebbens(_at_)sgi(_dot_)com>      http://reality.sgi.com/stebbens

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