Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The DumpText Plugin

DumpText is a demo plugin, but is in itself quite useful; it'll dump the "decoded, stripped" rendering of the text, as used by body rules, to STDERR. This is pretty handy for rule developers (and the curious).

...

No Format
loadplugin Dumptext dumptext.pm
body DUMPTEXT eval:dumptext()

Wiki Markup
(_WARNING: this won't work until \[http://bugzilla.spamassassin.org/show_bug.cgi?id=3717 bug 3717\] is fixed._)

dumptext.pm:

No Format
package Dumptext;

use strict;
use Mail::SpamAssassin;
use Mail::SpamAssassin::Plugin;
our @ISA = qw(Mail::SpamAssassin::Plugin);

sub new {
  my ($class, $mailsa) = @_;

  # the usual perlobj boilerplate to create a subclass object
  $class = ref($class) || $class;
  my $self = $class->SUPER::new($mailsa);
  bless ($self, $class);

  $self->register_eval_rule ("dumptext");
  return $self;
}

sub dumptext {
  my ($self, $permsgstatus) = @_;
  my $array = $permsgstatus->get_decoded_stripped_body_text_array();
  my $str = join (' ', @$array);
  $str =~ s/\s+/ /gs;
  print STDERR "text: $str\n";
  0;
}

1;

...