procmail
[Top] [All Lists]

Re: Unknown User errors

1998-03-31 00:59:30
On Mon, 30 Mar 98 09:27:05 -0500, Timothy J Luoma
<luomat+Lists/procmail(_at_)luomat(_dot_)peak(_dot_)org> wrote:
Try this instead:
REPLYTO=`formail -rtzxTo:`
:0
* ^Subject:.*test
| (echo 'OK' | Mail -s "NCI t_e_s_t OK" $REPLYTO)

Of course, if this is really all you want to do, a more idiomatic way
of doing it is something along the lines of 

    :0
    * ! ^X-Loop: tremors(_at_)newjackswing\(_dot_)dyn\(_dot_)ml\(_dot_)org
    * ^Subject:.*test
    | ( formail -rt -I "Subject: NCI t_e_s_t OK" \
            -A "X-Loop: tremors(_at_)newjackswing(_dot_)dyn(_dot_)ml(_dot_)org" 
;
        echo "Yup." ) | $SENDMAIL $SENDMAILFLAGS -t

While perhaps looking more complicated, this is easy to extend with
more stuff, such as, for instance, a different From: line, or a better
subject line (by default, formail would keep the old sub with a Re:
added in front if it didn't have one already, which is IMHO much
better for the recipient than a completely new auto-ack Subject line,
but you could grab the old Subject into MATCH and use it in a
different fashion too)... Here's an overworked example:

    :0
    * ! ^X-Loop: tremors(_at_)newjackswing\(_dot_)dyn\(_dot_)ml\(_dot_)org
    *   ^Subject:(.*\<)?test\>
    *   ^Subject:[      ]*(\<*Re:?)*[   ]*\/([^r        :]|r[^e]|re[^: ])?.*
    | (formail -rt -A "Precedence: junk" \
        -A "X-Loop: tremors(_at_)newjackswing(_dot_)dyn(_dot_)ml(_dot_)org" \
        -I "From: Autoresponder 
<tremors(_at_)newjackswing(_dot_)dyn(_dot_)ml(_dot_)org" \
        -A 'Reply-To: "Please don't reply" 
<nobody(_at_)newjackswing(_dot_)dyn(_dot_)ml(_dot_)org' \
        -I "Subject: Automatic reply Re: $MATCH" ; \
      echo "Got your message. Seems things are working fine now." ; \
      echo "-- " ; \
      cat $HOME/.signature ) | $SENDMAIL $SENDMAILFLAGS -t

The Re: handling is not really up to snuff but works with the
"normally pathological" cases as far as I've tested it. 
  Thinking of yet more stuff you might want to add is left as an
exercise for the eager :-)
  Note that formail will also add References: and In-Reply-To: which
is nice for those with a threading mail reader, and hard to do with
just a shell script.

Of course there's an opportunity for an incredibly nasty mail loop
here if someone should forge an email to be From/Reply-To
'tremors(_at_)newjackswing(_dot_)dyn(_dot_)ml(_dot_)org' (since your reply 
doesn't check
for an X-Loop, and the Subject: you send back has the word "test"
in it also! That's why I changed it to 't_e_s_t'

This solves this, too. Basically the X-Loop stuff is just another
example of how the basic recipe can be extended (but one that should
always be there when you're toying with autoresponders).

/* era */

Tangentially, note the \< \> tokens around the word "test". This will
prevent it from accidentally matching on anything like
"gastrointestinal" ... Anyway, it's beyond me why you're using
anything more than

    * ^Subject:[        ]*test[         ]*$

which is what I'm guessing you really mean to catch, and nothing else.
(The whitespace in the [] brackets are a tab and a space, as usual.)

-- 
 Paparazzi of the Net: No matter what you do to protect your privacy,
  they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>

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