Hi

Look in man perldoc Mail::SpamAssassin::Plugin for the definition of a
new plugin (for example MyFilter)

You could do a lot of interesting things inside the plugin
with the Mail::SpamAssassin::PerMsgStatus element (again perldoc ...)



A rough example (this works for older spamassassin, 
you really should look at those man pages)



package Mail::SpamAssassin::Plugin::MyExampleFilter;

use Mail::SpamAssassin::Plugin;
use strict;
use warnings;

use vars qw(@ISA);
@ISA = qw(Mail::SpamAssassin::Plugin);

# constructor: register the eval rule
sub new {
        my $class = shift;
        my $mailsaobject = shift;

        # some boilerplate...
        $class = ref($class) || $class;

        my $self = $class->SUPER::new($mailsaobject);
        bless ($self, $class);

        # the important bit!
        $self->register_eval_rule ("my_example_filter");


        return $self;
}

# and the eval rule itself
sub my_example_filter {
        my ($self, $permsgstatus) = @_;
        Mail::SpamAssassin::dbg("myexamplefilter: processing " . join(
", ", $pe
rmsgstatus->get('MESSAGEID') ) . " Envelope From=" .
$permsgstatus->get('Envelo
peFrom') );
        return 0;
}

And finaly in a .cf 

loadplugin     Mail::SpamAssassin::Plugin::MyExampleFilter
header         MYEXAMPLEFILTER eval:my_example_filter()
(You could put plugin configs here also)




I think this question has been answered a couple of times,
probably in a better way than this.


Saludos
--
Leonardo Helman
Pert Consultores
Argentina


On Tue, Aug 14, 2007 at 03:15:04PM -0500, C. Bensend wrote:
> 
> Hey folks,
> 
>    This is a question about using SpamAssassin's perl interface, not
> about filtering mail.
> 
>    I'm using 3.2.2 (soon to be 3.2.3) on OpenBSD, built from source.
> In addition to using SA to filter my email, I'd also like to take
> advantage of SA's ability to parse Received headers for my own
> project.
> 
>    I store the entire spam in a database.  What I want to do is to
> be able to parse out the Received headers' IP addresses from the
> full text of each email.  I only really need the IP that hands off
> to my own servers, but it would be useful to get an array of all of
> them.
> 
>    I am not at all a perl guru - I've written quite a bit of it,
> but more complex stuff than my simple scratchings makes my brain
> swell and hurt.  If someone could give me a quick leg up in going
> from a variable containing the entire message to an array of IPs
> (or just the handoff IP, that's fine), I'd really appreciate it.
> 
> Thanks a bunch!
> 
> Benny
> 
> 
> -- 
> "This officer's men seem to follow him merely out of idle curiosity."
>                                -- Sandhurst officer cadet evaluation

Reply via email to