--3TjJaq4Yth4AkTaU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Jul 14, 2007 at 09:54:36AM -0300, James MacLean wrote:
> Where do I find information on hooking into post_message_parse()? Tried=

=20
> greping in the module area with no luck . Certainly agree it would be=

=20
> better to get the text out and let everyone at it .


You can ask. But yes, I didn't do a good job of fully documenting how
this is supposed to work -- you have to know about the plugin call, then
hunt around Message and Message::Node, etc. Sorry. Here's the basics:

First, create a plugin with the post_message_parse method. Then in
there, use $msg->find_parts() to find the parts that you're looking
for (find_parts() is pretty well documented). Then, you simply take
the data from $part->decode() and do something to convert it to text.
Then you take that text and call $part->set_rendered($text).

Later on, when SA looks for the text to use for body rules, uri parsing,
etc, it takes anything that has rendered text.

So here's a quick n' dirty sample that takes parts of "image/theo" and
"renders" them into "The plugin works!\n":

------------
package Mail::SpamAssassin::Plugin::RenderExample;

use Mail::SpamAssassin::Plugin;
use strict;
use warnings;

use vars qw(@ISA);
@ISA =3D qw(Mail::SpamAssassin::Plugin);

sub new {
my $class =3D shift;=20
my $mailsaobject =3D shift;
$class =3D ref($class) || $class;
my $self =3D $class->SUPER::new($mailsaobject);
bless ($self, $class);
return $self;
}

sub post_message_parse {
my ($self, $opts) =3D @_;
my $msg =3D $opts->{'message'};
foreach my $p ( $msg->find_parts(qr!^image/theo$!, 1) ) {
$p->set_rendered("The plugin works!\n");
}
}

1;
------------

--=20
Randomly Selected Tagline:
"I'm a programmer: I don't buy software, I write it." - Tom Christiansen

--3TjJaq4Yth4AkTaU
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFGmQRSamwUIkXWD1cRAjzyAJ9pXXywPlNoqm1XxQ07S0 UAsRkakgCfRtb0
8RHYpvdm1eBV5npUf0K5mLA=
=dGZg
-----END PGP SIGNATURE-----

--3TjJaq4Yth4AkTaU--