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

Sam Varshavchik <[email protected]>
Newsgroups gmane.mail.maildrop
Message-ID <[email protected]>
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.

------------------------------------------------------------------------------
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

_______________________________________________
Courier-maildrop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/courier-maildrop
signature.asc (application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)

iQIcBAABAgAGBQJST1JfAAoJEGs6Yr4nnb8lqeUP/3iZZ9OWAdu2Cz9W+AgvRs+H
TRjWyVmkuxVW1nucZPPDQtdImiPObTp8ABV1HPFaBUS+rMR3Bgqui3uckzhLxw5O
DMBBWA8pcxJnNX4dJ6MVEHv2DzHqU126FZVNOvK6U18qKAoz+D6Olubc2aQKx1tm
68LKtEfGSI0L60BIxbQfjrZVYYsX2WBcY6+lb8rXXTDU9PQw6OIq11VEpdM+DRGY
qdFaPQ2HmDn4l8MCk/v/BPeZzDSidmw0gPhMs1vHXkjA/c19Mdy7GihWOtAIOTpN
yOYt3rXtBdl+e5mc0iS9xKG58U3+4aUtNPy1cTWvjzCPspoqdfywlZGWLVbKe/dI
IU04PidE6BAESxZ0QcEF0RDgNJXzx9Q1Rwxq2UBDvfYLnENHfMRelZW0axUlFF54
OwGsLDsqZaygnlztvt6WJ5MMEZCt4LEw42vYn8eWmYE5f2pw3il8Lyqsaz2TS/hV
SJCRMg4x5cUmBv9/EB2V0DfPeOzbWPf4GUda2ljlmmYKVyoGHg4dPMzNxT/pHD1G
FKp9mKH+SwxT+MkENaiD+YKduBJmX8gXmfjjrLigcv/wjOU9sJtc36xsdXEZWatS
PyZHd92NxKthki2YNnAhBv4ZFE+AiL5zkQ6K+JxIgtTMQaX2iv5jUW5Oi+G1pSOa
eR1GKZCYW7y8PeFNTzwo
=hzJr
-----END PGP SIGNATURE-----
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.