http://bugzilla.spamassassin.org/show_bug.cgi?id=3759





------- Additional Comments From [EMAIL PROTECTED]  2004-09-08 15:52 -------
Here you go:

local.cf
--------
loadplugin Mail::SpamAssassin::Plugin::empty_body
body     E_EMPTYBODY eval:esoft_empty_body()
describe E_EMPTYBODY Body is empty
score    E_EMPTYBODY 2.5

zz_local_cf:
------------
report_safe 0
required_hits 5
auto_whitelist_path /var/spool/mail/.spamassassin/auto-whitelist
auto_whitelist_file_mode 0666
bayes_path /var/spool/mail/.spamassassin/bayes
skip_rbl_checks 1
rbl_timeout 10
use_dcc 0
dcc_timeout 10
dns_available no

loadplugin Mail::SpamAssassin::Plugin::another
another_value 20

emptybody.pm
------------
=head1

To try this out, write these lines to /etc/mail/spamassassin/plugintest.cf:

  loadplugin     Mail::SpamAssassin::Plugin::empty_body
  header         E_EMPTYBODY eval:empty_body()

=cut

package Mail::SpamAssassin::Plugin::empty_body;

use Mail::SpamAssassin::Plugin;
use strict;
use bytes;

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 ("empty_body");

  print "registered Mail::SpamAssassin::Plugin::empty_body: $self\n";
  return $self;
}

# and the eval rule itself
sub empty_body {
  my ( $self, $msg ) = @_;

  my $textary = $msg->get_decoded_stripped_body_text_array();

  return 1 if ( join('', @{$textary} ) =~ /^\s*$/ );
#  return 1 if ( $msg =! /^\s*$/ );
  return 0;
}

1;

another.pm
----------
=head1

To try this out, write these lines to /etc/mail/spamassassin/plugintest.cf:

  loadplugin     Mail::SpamAssassin::Plugin::another
  header         E_EMPTYBODY eval:another()

=cut

package Mail::SpamAssassin::Plugin::another;

#use Mail::SpamAssassin::Conf;
use Mail::SpamAssassin::Plugin;
#use Mail::SpamAssassin;
sub dbg { Mail::SpamAssassin::dbg (@_); }
use strict;
use bytes;

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

  my $conf = $mailsaobject->{conf};
  $conf->{another_value} = 1;

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

  print "registered Mail::SpamAssassin::Plugin::another: $self\n";
  return $self;
}

sub another{
  my ( $self, $msg ) = @_;
  return 0;
}

sub parse_config {
  my ($self, $opts) = @_;

  my $conf = $opts->{conf};
  my $key = $opts->{key};
  my $value = $opts->{value};

  dbg("You'll never see me in the logs with this bug!");
  if ( $key eq 'another_value' ) {
         $self->{main}->{conf}->{esoft_required_hits_learn} = $value;
         return $Mail::SpamAssassin::Plugin::INHIBIT_CALLBACKS;
  }

  return 0;
}

1;



------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

Reply via email to