procmail
[Top] [All Lists]

Re: Database checks into procmail

2002-01-06 13:10:57
At 12:04 2002-01-06 +0100, Nils Vogels wrote:
a) email arrives at procmails door
b) procmail looks up the features the recipient has enabled using a sql
db

In mid-December, I posted the basis for something which would allow you to do a similar thing -- you'd use an external program to do the lookup, and return the features in a string. Procmail would then check that string for featurenames. Start in the archives with the following link, then read the thread:

<http://www.rosat.mpe-garching.mpg.de/mailing-lists/procmail/2001-12/msg00379.html>

In my example, it was obtaining the output from a simple egrep, but if you had a small perl or C++ program that performed the SQL and emitted the results to STDOUT, that would work just the same.

c) rule 1 is invoked because the feature is enabled
d) rule 2 is skipped, because the feature is disabled

Using the format provided in the example I posted in the aforementioned thread, you would have something like so at the top of each filter:

:0
* $FILTER_OPTIONS ?? [  ]TRASHMOUTH\>

(where $FILTER_OPTIONS is the string which the output from the DB command was emitted to, and TRASHMOUTH is, in this case, the name of the current filter and the string which is present in the DB if the filter is enabled (or your db lookup program can correlate individual field bits to output name strings - you don't necessarily have to have each filter name stored in your db as text for each and every one of your 10,000 users or whatever).

The main part im wondering about is how to get procmail to talk to a sql
db.. does anyone have any experiences with this ?

Procmail itself won't do the talking - you'd use a small helper application. You could pass SQL queries on the commandline to that helper if you so chose, but if you just return *ALL* the rule flags back in one string, you can make *ONE* call to the helper script, rather than several dozen (or however many rules you may have).

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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