Re: Ability to match against message body using lookup()

Darren Spruell <[email protected]>
Newsgroups gmane.mail.maildrop
Message-ID <[email protected]>
On 10/04/2013 04:42 PM, Sam Varshavchik wrote:
> Darren Spruell writes:
> 
>> Greetings,
>> 
>> I have a use case where I have short but growing list of patterns
>> I'd like to match against for filtering. I'd like the matches to
>> be limited to the Subject header and message body (but no other
>> headers). I also like the capability lookup() provides to stash
>> patterns in a file (with comments/etc.). I can see from the
>> documentation that matching against a concise expression (e.g.
>> $MATCH1 from a header match) using lookup() is easy, but how can
>> you handle an expressions that matches against the message body
>> generally? Is it valid/correct to do something remotely like
>> this?
>> 
>> if ( /^Subject:\s*(.*)/ && lookup( $MATCH1, "interesting.dat" )
>> || lookup( //:b, "interesting.dat" ) ) { # Do stuff }
> 
> The only way to do a full-body scan would be something like this:
> 
> foreach /.*/:b { if (lookup($MATCH, "interesting.dat")) { …
> 
> Body lookups will get done one line at a time. This will be slow,
> but, for personal use, and not overly large mail, this should be
> fine; but you'll want to make sure that you're running the current
> version of maildrop, which properly MIME-decodes message bodies,
> before matching them.

Thanks! I'll give this is a shot and see how it works.

DS

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.