This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Current »

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


loadplugin Dumptext
body DUMPTEXT eval:dumptext()

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

sub new {
  my ($class, $mailsa) = @_;
  $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";


How To Use It

Save the two files above into a new directory called dumptext, then use spamassassin's -c switch so that it reads that directory for rules:

./spamassassin -L -t -c dumptext < spammail > /dev/null


./spamassassin -L -t -c dumptext < sample-nonspam.txt > /dev/null
text: TBTF ping for 2001-04-20: Reviving -----BEGIN PGP SIGNED MESSAGE----- TBTF
ping for 2001-04-20: Reviving T a s t y B i t s f r o m t h e T e c h n o l o g
y F r o n t Timely news of the bellwethers in computer and communications techno
logy that will affect electronic commerce -- since 1994 Your Host: Keith Dawson 
ISSN: 1524-9948 This issue: [....etc.]

You can also scan a massive selection of mail using either mass-check's
-c switch, or with the mailbox-scanning support added to the spamassassin script in SpamAssassin 3.0.0.


  • No labels