On Mon, Feb 07, 2005 at 10:19:06AM +0100, Struan Bartlett said:
> Thanks Simon! How do I get hold of the patched code?

I'm going to reelease today or you can get it from svn at 

        http://siesta.unixbeard.net/svn/trunk/Email-Store/
 

> P.S. It says in the Email::Simple man page, "Email::Simple handles only 
> RFC2822
> formatted messages. This means you cannot expect it to cope well as the only
> parser between you and the outside world, say for example when writing a mail
> filter for invocation from a .forward file (for this we recommend you use
> Email::Filter anyway)."

Err, I'm not entirely sure what you mean here.

Email::Simple and Email::MIME take the text of an rf822 email message 
and turn it into an object. What you do with that object is up to you. 
If you want to filter it then use Email::LocalDelivery and some 
handrolled regexes. Or, more succinctly, use Email::Filter.

For example, I have this in my .procmailrc

  # dnsbl
  :0 Wc
  * < 256000
  | $HOME/bin/proxy-lookup

with proxy-lookup looking like

#!/usr/local/bin/perl -w

use strict;

use Email::Simple;
use Net::DNSBLLookup;

my $mail = Email::Simple->new(join "", <>);
my $dnsbl = Net::DNSBLLookup->new(timeout => 1);


my $return = 0;
for (reverse  $mail->header('received')) {
        next unless /(\d+\.\d+.\d+\.\d+)/;
        my $res = $dnsbl->lookup($1);

        my ($proxy, $spam, $unknown) = $res->breakdown;

        my $num_responded = $res->num_proxies_responded;

        my $proxy_score = ($proxy + $unknown/2) * 10 / $num_responded;
        my $spam_score = ($spam + $unknown/2) * 10 / $num_responded;

        print "lookup of $1 resulted in proxy score ".
              "$proxy_score and spam score $spam_score\n" 
               if $ENV{PROXY_DEBUG};

        $return ||= ($proxy_score + $spam_score > 1);

}

exit $return;




Reply via email to