[prev in list] [next in list] [prev in thread] [next in thread] 

List:       amavis-user
Subject:    [AMaViS-user] Amavisd & Custom SpamAssassin Plugins (Tips?)
From:       Jack Stewart <jstewart () imss ! caltech ! edu>
Date:       2006-01-31 17:20:50
Message-ID: 43DF9C72.2020502 () imss ! caltech ! edu
[Download RAW message or body]


Hi,

I'm trying to write a simple plugin for SpamAssassin.  When I run a test 
on the command line against test messages, it works just fine.  But 
amavisd is not returning a result on the test.

Anyone have any tips for writing SpamAssassin plugins with Amavisd?  Is 
there something simple I'm missing?  Does amavis not pass image 
attachments to SpamAssassin?

Here is the current version with just one of the tests:

--snip--
package Mail::SpamAssassin::Plugin::ImageCheck;

use Mail::SpamAssassin::Util;
use Mail::SpamAssassin::Plugin;
use Mail::SpamAssassin::Message;
use Image::Info qw(image_info dim);
use strict;
use warnings;
use bytes;
use vars qw(@ISA);
our @ISA = qw(Mail::SpamAssassin::Plugin);

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("check_image_size");
  return $self;
}

sub check_image_size {
  my ($self, $pms) = @_;
  $self->_check_image_size ($pms, 0) unless exists $pms->{check_image_size};
  $pms->{check_image_size};
}

sub _check_image_size {
  my ($self, $pms) = @_;
  $pms->{check_image_size} = 0;
  my $max =35000;

  foreach my $part ( 
$pms->{msg}->find_parts(qr/^image\/(gif|jpg|png|bmp|tiff|jpeg)/) )
  {
    my $current_image = $part->decode();
    my $size = length($current_image);
    $| = 0 ;
    if ( $size < $max ) {
      $pms->{check_image_size} = 1;
      return 1;
    }
  }
  return $pms->{check_image_size};
}
--snip--
The plugin is getting loaded in init.pre and the eval is defined in 
local.cf.  The package is based on both the Test.pm and SPF.pm. 

Any pointers are greatly appreciated.

---Jack






-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic