You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Paul Lenz <pa...@lenz-online.de> on 2007/08/12 11:05:21 UTC

How to write my own plugin

Actually I write Perl programs since many years, but I am not so
familiar
with the object oriented programming and I can not discover the
secrets
of Spamassassin. Contretely: I was not able to access the body of a
mail.

I included Plugin\Test.pm into my configuration and gave it a score of
0.1.
This worked, each mail got this score.

In the sub with the line "hard work goes here..." (how true!!!) there
are
the scalars $self and $permsgstatus. I added some code which saves
$self into a file. The result was a hash reference. I tried keys() and
found
the key "main". Sounds promising, doesn't it? But the result was
another
hash reference. It's keys didn't look like the message body. I gave it
up.

I looked into some other plugins and ended with this code:
  my ($self, $permsgstatus) = @_;
  my $array = $permsgstatus->get_decoded_stripped_body_text_array();
  my $text = join (' ', @$array);

But $text contains only "I need to make this message body somewhat
long
so TextCat preloads I need to make this message body somewhat long so
TextCat preloads ......"