procmail
[Top] [All Lists]

Re: Overlapping Problem

1999-02-28 20:33:15
"Mike Watkins" <mwatkins(_at_)promotion4free(_dot_)com> writes:
I have a CGI script which creates an autoresponder for every member in its
database.  For some customers, there are probably going to be thousands of
members.  Each member gets a free autoresopnder, 
USERNAME(_at_)mydomain(_dot_)com(_dot_)

Here's an example of the few lines which the script writes to the
.procmailrc file for each member:

So, each member has his or her own UNIX account and the lines like
the ones below will be placed in each user's .procmailrc, right?


===============================

#mwatkins(_at_)mydomain(_dot_)com
:0
* ^To:(_dot_)*mwatkins(_at_)mydomain(_dot_)com
{
      FROM=`formail -rtzxTo:`
      SUBJECT=`formail -rtzxSubject:`
      TO=`formail -tzxTo:`

      :0i
      | /usr/www/mysite/cgi-bin/process.pl
}
#mwatkins(_at_)mydomain(_dot_)com

=============================

Since every recipe is EXACTLY the same for every member except for the
condition, I was wondering if it's possible to have one recipe in the
.procmailrc file to handle all members, then have all of the addresses for
the autoresponders stored in a text file, so I could have just one condition
like:
      * To:.*`cat addresses.txt`

That won't work, as you probably discovered, and it probably is not
what you want to do.  If you answered my question above with a "yes",
then the above is a bad idea because procmail knows what user is
involved when it gets to an rcfile.  For example, if it gets to the
above lines in your .procmailrc, then it only needs to look for
"mwatkins" in the recipient lines, not for any of the users with a
bounce going.  If you're feeling lazy you could even use $LOGNAME in
the condition:

        :0
        * $ ^TO_$LOGNAME(_at_)mydomain(_dot_)com

Note that you should use ^TO_ as that will catch both To: and Cc:
headers and not mismatch on substring addresses.  If you don't have
procmail 3.11pre4 or later then you'll need to upgrade first (but wait
a week, as a little bird told me that version 3.12 will be out in a few
days).

The other change I would suggest is to only use formail for the FROM
variable.  The perl script should be able to get the Subject: header
pretty easily, and instead of using $ENV{TO} it should be able to use
$ENV{LOGNAME} (though that doesn't have the domain part).


Philip Guenther

<Prev in Thread] Current Thread [Next in Thread>
  • Re: Overlapping Problem, Philip Guenther <=