package DspamHeader; use Mail::SpamAssassin::Plugin; our @ISA = qw(Mail::SpamAssassin::Plugin); our $VERSION = "1.0.0"; sub new { my ($class, $mailsa) = @_; # the usual perlobj boilerplate to create a subclass object $class = ref($class) || $class; my $self = $class->SUPER::new($mailsa); bless ($self, $class); # then register an eval rule, if desired... $self->register_eval_rule ("dspam_headers"); # and return the new plugin object return $self; } sub dspam_headers { my ($self, $permsgstatus, $result, $min, $max) = @_; my $dspam_result = trim($dspam_result = $permsgstatus->get('X-DSPAM-Result')); my $dspam_confidence = trim($dspam_confidence = $permsgstatus->get('X-DSPAM-Confidence')); if ($dspam_result =~ /Spam/) { if (($dspam_confidence ge $min) & ($dspam_confidence lt $max)) { return 1; } else { return 0; } } else { return 0; } } 1; sub trim { @_ = $_ if not @_ and defined wantarray; @_ = @_ if defined wantarray; for (@_ ? @_ : $_) { s/^\s+//, s/\s+$// } return wantarray ? @_ : $_[0] if defined wantarray; }