procmail
[Top] [All Lists]

RE: Querying a DB to determine destination mailbox for an email usingProcmail

2011-10-27 21:47:12
Thanks for the prompt response.

My requirement does need a database based approach because:
(a) The values for key/value combination will be maintained using a
different application (to be designed) that is used by Business folks.
(b) The values would change dynamically as and when Business changes
them at different times of the week/weekend (when emails need to be
handled by different teams at different times).

If we maintain those values in a delimited flat file, business folks
(who may not have access to the system or may not have the technical
background to change the value) won't be able to update it at different
times of the week.

Regards,
Komal

-----Original Message-----
From: procmail-bounces(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
[mailto:procmail-bounces(_at_)lists(_dot_)RWTH-Aachen(_dot_)de] On Behalf Of 
LuKreme
Sent: Thursday, October 27, 2011 6:57 PM
To: procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
Subject: Re: Querying a DB to determine destination mailbox for an email
usingProcmail


On 27 Oct 2011, at 18:58 , Komal Tagdiwala (ktagdiwa) wrote:

Requirement: I need to devise a solution where a procmail script can
dynamically determine the final destination mailbox by querying a
database for a particular keyword to get the corresponding mailbox.

Approach I have in mind:
Based on my knowledge of procmail so far, I envision the following
steps but wanted some expert opinion on finding the right approach.
1. Use a database to maintain a key/value pair type information for a
keyword and a corresponding mailbox name. This information may be
maintained manually or using a custom application (outside of procmail).
2. Write a Perl script which takes an input parameter from procmail (I
have not done this before but I believe procmail can call a Perl script
and just pass an argument in the call). 

If it is simply a matter of key/value pair, then it is much easier to
use grep.

# I think Sean wrote this, essentially.

:0 h
CLEANFROM=|formail -IReply-To: -rtzxTo:

WHITELIST=$HOME/.friends
ISLISTED=`grep -i "^$CLEANFROM " $WHITELIST`
:0
* ISLISTED ?? ^[^ ]+[   ]+\/[^  ]+
$MATCH

.friends
email1(_at_)example(_dot_)com Friends
email2(_at_)example(_dot_)com Mom
email3(_at_)example(_dot_)com Bob
email4(_at_)example(_dot_)com Friends

3. The Perl script performs the actual query to database for a given
keyword to find the corresponding mailbox name.

If you need to query an actual database, then yes you will need an
external script to do it.

4. The script then returns the mailbox name to the procmail
script/recipe that invoked the Perl script.

That won't work, the procmail recipe has to either wait for success, or
assume success. This will be the hangup.

If yes, are there any conditions that I missed in my approach that I
need to be mindful of before beginning research and development for this
solution using this approach?

The biggest issue is that your procmail deliveries will come to a
complete stop while your query script runs. This might be a critical
flaw, a minor annoyance, or of no importance at all.

--
The only way of discovering the limits of the possible is to venture a
little way past them into the impossible.


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail