RE: Querying a DB to determine destination mailbox for an email usingProcmail
"Komal Tagdiwala (ktagdiwa)" <[email protected]>
| Newsgroups | gmane.mail.procmail |
|---|---|
| Message-ID | <40966CDBEF22C64F84F20BD68D445B2101A574B8@xmb-sjc-212.amer.cisco.com> |
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: [email protected] [mailto:[email protected]] On Behalf Of LuKreme Sent: Thursday, October 27, 2011 6:57 PM To: [email protected] 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 [email protected] Friends [email protected] Mom [email protected] Bob [email protected] 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/ [email protected] http://mailman.rwth-aachen.de/mailman/listinfo/procmail