procmail
[Top] [All Lists]

Re: filter based on body keywords?

2005-04-29 06:00:38
I am trying to implement a filter based on keywords on the body of the email. Basically this is what i want to do:
Keywords: WORD1, WORD2, WORD3, KEYWORD5, BOB
My filter should see if the content of all email to john(_at_)example(_dot_)com contains: WORD1 or WORD2 or WORD3 or KEYWORD5 or BOB, and then
deliver the good mail to john(_at_)example(_dot_)com(_dot_) Otherwise, the email
missing any of the above keywords should go to the "spam" mailbox.

  There are probably better ways to handle it, but I do something
like this, which also requires an additional script.  Basically, I
have a file called "good_body", which is nothing more than a newline
delimited list of words which are considered "good", and indicate
an automatic submission to the specified user.

  The additional script simply creates procmail recipe lines, that
do the checking.  These recipe lines are added to my procmailrc
automatically as the file to checked for changes and the like.
Michelle's suggestion is definitely more attractive, in that it
keeps your procmail file small. However, I want more information
in my procmail log file, which indicates why the message was
accepted (to track problems/bugs if they arise).  My script
basically does this:

* creates groups of 10 keywords
* creates a unique 6-char hex hash of group
* builds procmail recipe which:
   .  checks for existence of any keyword in group
   .  if exist:
      * header item containing hex hash is added to email
      * LOG file entry with hex hash is written
      * email is delivered

It makes my rc file ugly as all get out, but the perk, for me, is
that if an email makes it through that I think shouldn't have, all
I need is the hex hash from the email or LOG file, and can quickly
identify why it was accepted, and then tweak the keywords as needed.

Not the most elegant solution, but it works. (=

____________________________________________________________
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

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