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:19:51 UTC

How can I 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:

loadplugin     Mail::SpamAssassin::Plugin::Test
full           MY_TEST1 eval:check_test_plugin()
score          MY_TEST1 0.1
describe       MY_TEST1 Test-Plugin

This workes, each mail gets 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 ......". I gave it up.

Would please somebody give me a hint how to access the body of 
the mail? 

Thanks, Paul Lenz


PS. Sorry for multiple postings, I only saved my message during 
editing, but it seems to be sent every time :(

 


Re: How can I write my own plugin?

Posted by jdow <jd...@earthlink.net>.
From: "Paul Lenz" <pa...@lenz-online.de>

> 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:
> 
> loadplugin     Mail::SpamAssassin::Plugin::Test
> full           MY_TEST1 eval:check_test_plugin()
> score          MY_TEST1 0.1
> describe       MY_TEST1 Test-Plugin
> 
> This workes, each mail gets 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 ......". I gave it up.

What did the body of the email you are testing look like?

I am suspecting it looked something like:

I need to make this message body somewhat long so TextCat preloads
I need to make this message body somewhat long so TextCat preloads

etc.

The newlines are stripped as are some other elements of the message
leaving it as a long line of text for that particular means of getting
the message body.

{^_^}