Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: How can I write my own plugins?

From: Alex Woick <alex(at)wombaz.de>
Date: Sun Aug 12 2007 - 07:50:59 EDT


Paul Lenz wrote on 12.08.2007 11:23:

> 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.

You should consult "man perltoot" first - it's "Tom's Object-Orientated Tutorial For Perl" to learn about the basics. Without that, it is very difficult for you to decipher the structure and the usage of the objects. SpamAssassin uses derived classes, so you might not find methods ("functions") in the packages where you are expecting them - that may be one of the many mysteries to you.

The absolutely short definition of perl's object orientation is probably something like this:
- an "object" is an ordinary reference that gets a package name ("class name") tagged to it with the bless() function - if you call a function like $object->my_function($param), perl searches for sub my_function in the package that is tagged to $object, and then it calls my_function($object, $param). - Perl does not only search the tagged package for a function, but also recursively each package that is listed in the @ISA array, which can be declared in each class package. So you can not only use the sub's in your class but also all sub's of the referenced classes ("super classes"). - the most used reference to use as an object is a hash reference, but you can use every reference type in bless().

> 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?

This is already very good. You have it. That text is the text of the internal test message that is processed on every SpamAssassin startup or --lint. Received on Sun Aug 12 07:52:21 2007

This archive was generated by hypermail 2.1.8 : Tue Oct 23 2007 - 23:17:05 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library