3
To try this out, write these lines to /etc/mail/spamassassin/plugintest.cf:
5
loadplugin myTestPlugin
6
header MY_TEST_PLUGIN eval:check_test_plugin()
12
use Mail::SpamAssassin::Plugin;
13
use Mail::SpamAssassin::Logger;
17
our @ISA = qw(Mail::SpamAssassin::Plugin);
19
# constructor: register the eval rule
22
my $mailsaobject = shift;
25
$class = ref($class) || $class;
26
my $self = $class->SUPER::new($mailsaobject);
27
bless ($self, $class);
30
$self->register_eval_rule ("check_test_plugin");
31
$self->register_eval_rule ("check_return_2");
32
$self->register_eval_rule ("sleep_based_on_header");
34
print "registered myTestPlugin: $self\n";
38
# and the eval rule itself
39
sub check_test_plugin {
40
my ($self, $permsgstatus) = @_;
41
print "myTestPlugin eval test called: $self\n";
43
print "test: plugins loaded: ".
44
join(" ", sort $self->{main}->get_loaded_plugins_list()).
47
my $file = $ENV{'SPAMD_PLUGIN_COUNTER_FILE'};
49
open (IN, "<$file") or warn;
50
my $count = <IN>; $count += 0;
53
dbg("test: called myTestPlugin, round $count");
55
open (OUT, ">$file") or warn;
63
sub sleep_based_on_header {
64
my ($self, $permsgstatus) = @_;
65
my $secs = $permsgstatus->{msg}->get_header("Sleep-Time");
69
warn "sleeping for $secs seconds...";
80
sub extract_metadata {
81
my ($self, $opts) = @_;
82
my $msg = $opts->{msg};
83
print "myTestPlugin extract_metadata: $self\n";
84
$msg->put_metadata("Plugin-Meta-Test", "bar");
89
my ($self, $permsgstatus) = @_;
90
print "myTestPlugin finishing: $self\n";