procmail
[Top] [All Lists]

Re: customer service processor with 3 attempt limitation

1999-10-25 23:20:01
David Gikandi <myprocmail(_at_)yahoo(_dot_)com> writes:
...
I am trying to limit procmail to responding to emails
to only 3 instances. To ask this question properly, I
think some background info is necessary:
...
But, there is still a problem if the person emailing
uses a new subject line each time and fails to include
the strings received so far.

I was wondering, to prevent this, how do i add extra
headers into all responses that will 'stick' with the
emails as they are emailed in and responded to back
and forth? The problem with X-Loop as I understand it
...
way, no matter what the person does with the subject
and body on each reply, as long as thet reply by
hitting their Reply button on their email client, it
will not autorespond with an answer after the 3rd
time. How can I achieve this?

If someone is hitting the reply button and then deleting the body and
changing the Subject:, then the only things being carried from the
auto-reply message to their reply would be
a) the reply address; and
b) the Message-Id:, but only if their mail reader generates an
   In-Reply-To: or References: header.

Assuming you choose the former, you'll need to have multiple address
refer to the auto-reply address.  With sendmail you can use
plus-addresses: if the auto-reply address is <help(_at_)domain(_dot_)com> then
addresses like <help+data-here(_at_)domain(_dot_)com> will also go to that
address.  If you were using procmail as the default local mailer then
the "data-here" bit would be made availible directly to procmail as $1,
but since you're using procmail via a .forward file you can't do that
and the best you can do is match against the header.  Since the
"data-here" part will only matter on replies, this shouldn't be a
problem, as replies should always include the address in the header.
So, you can just do a match with ^TO_ and try to capture a +data part
after the address, ala:

        :0
        * ^TO_help\+\/[^(_at_)]+
        {
            # There was a plus part, assume it's list of reply
            # tokens/identifiers/cookies that we've already tried as
            # responses to this question.
            TRIED = $MATCH
        }


You'll need some way of encoding a list of "reply tokens".  Due to the
length limits on addresses: values, I would suggest choosing a
smallish, 'tight' encoding of the possible answers.  Even better is if
they're self-delimiting so that you can just pack them together in the
plus part.  For example, if you give each reply a token consisting of a
letter followed by a number, then you could latter check to see if a
given reply had already been sent by simply matching for the token in
the TRIED variable.  For example:

        # Reply a5: turn the capslock key off
        :0
        * ! TRIED ?? a5
        * (caps? *lock|(wrong|incorrect|bad) +pa?ssw(or)?d)
        {
            FILE = $HOME/replies/capslock
            TRIED = "${TRIED}a5"

            # send reply
            :0 w
            |(formail -rtk -I"Reply-To: <help+$TRIED(_at_)domain(_dot_)com>" 
.... ; \
              cat $FILE \
             ) | $SENDMAIL $SENDMAILFLAGS -t
        }


There are various tricks you can do from there to make things easier to
maintain.  For example, you can move the recipe that sends the reply to
the very end, after all the actual tests: just chain the tests with the
'E' flag and then send a reply if and only if the FILE variable was
set:

        :0
        * ! TRIED ?? a1
        * ...big regexp here...
        { TRIED = "${TRIED}a1"
          FILE = $HOME/replies/answer1
        }
        :0 E
        * ! TRIED ?? a2
        * ...big regexp here...
        { TRIED = "${TRIED}a2"
          FILE = $HOME/replies/answer2
        }
        :0 E
        ...etc
        { TRIED = "${TRIED}b7"
          FILE = $HOME/replies/answer33
        }

        # If FILE has been set to something, send a reply
        :0 w
        * FILE ?? .
        |(formail -rtk -I"Reply-To: <help+$TRIED(_at_)domain(_dot_)com>" .... ; 
\
          cat $FILE \
         ) | $SENDMAIL $SENDMAILFLAGS -t

        # FILE wasn't set, so we didn't have a match on a reply that we
        # haven't already sent.  Fall off the rcfile and let the message
        # be delivered to $DEFAULT


Does that make sense?


Philip Guenther

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