The CustomDeleteTag Plugin

This SpamAssassin plugin module allows users to specify, through a user preferences database, a value that will be added to the message header, for all messages, specifying what value/score it is safe to delete the message. Obviously, you need some other process that looks at this header and performs the action, since SpamAssassin only filters and does not delete.

Original mailing list thread.

Code

Add the following to your local.cf file:

loadplugin CustomDeleteTag CustomDeleteTag.pm

ifplugin CustomDeleteTag

  custom_delete_score 9.5

  add_header all Delete _CUSTOMDELETESCORE_

endif # CustomDeleteTag

CustomDeleteTag.pm:

=head1 NAME

package CustomDeleteTag

=head1 SYNOPSIS

  loadplugin CustomDeleteTag /path/to/CustomDeleteTag.pm

  custom_delete_score 9.5

  add_header all Delete _CUSTOMDELETESCORE_

=head1 DESCRIPTION

This SpamAssassin plugin module allows users to specify a value that will be added
to the message header, for all messages, specifying what value/score it is safe to
delete the message.  Obviously, you need some other process that looks at this
header and performs the action, since SpamAssassin only filters and does not delete.

=cut

package CustomDeleteTag;

use Mail::SpamAssassin::Plugin;
use strict;
use bytes;

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

sub new {
  my $class = shift;
  my $mailsaobject = shift;

  $class = ref($class) || $class;
  my $self = $class->SUPER::new($mailsaobject);
  bless ($self, $class);

  $self->set_config($mailsaobject->{conf});

  return $self;
}

sub set_config {
  my ($self, $conf) = @_;

  my @cmds = ();

  push(@cmds, {
               setting => 'custom_delete_score',
               default => 1000,
               type => $Mail::SpamAssassin::Conf::CONF_TYPE_NUMERIC,
              });

  $conf->{parser}->register_commands(\@cmds);
}

sub parsed_metadata {
  my ($self, $opts) = @_;

  $opts->{permsgstatus}->{tag_data}->{CUSTOMDELETESCORE} =
    $opts->{permsgstatus}->{conf}->{custom_delete_score};
}

1;

How To Use It

Add the above configuration to your local.cf file and watch for the custom delete header to start showing up in your mail messages.


CategorySoftware

CustomDeleteTag (last edited 2011-02-21 19:59:29 by Darxus)