← Documentation Index

NAME

Mailmunge::Test::SpamAssassin - run SpamAssassin against the current message.

ABSTRACT

This class runs SpamAssassin against the message and returns the SpamAssassin Mail::SpamAssassin::PerMsgStatus object that is the result of the SpamAssassin run.

You must have Mail::SpamAssassin installed to use this class.

SYNOPSIS

package MyFilter;
use Mailmunge::Test::SpamAssassin;

sub filter_begin {
    my ($self, $ctx) = @_;
    my $test = Mailmunge::Test::SpamAssassin->new($self);
    my $status = $test->spam_assassin_status($ctx);
    if ($status) {
        if ($status->get_score() >= 5) {
            $self->action_change_header($ctx, 'Subject', '[SPAM] ' . $ctx->subject);
        }
        $status->finish();
    }

    # ... rest of filter_begin
}

CLASS METHODS

Mailmunge::Test::SpamAssassin->new($filter)

Constructs a new Mailmunge::Test::SpamAssassin object and stores a copy of $filter in it.

INSTANCE METHODS

spam_assassin_status($ctx, $local_tests_only, $config)

Runs a SpamAssassin check against the current message. $local_tests_only is passed as the local_tests_only option to the Mail::SpamAssassin constructor. It is optional; if not supplied, it defaults to false.

$config is the path to the SpamAssassin userprefs_fileanem. If not supplied, Mailmunge uses the first file found out of:

    CONFDIR/sa-mailmunge.cf

    CONFDIR/spamassassin/sa-mailmunge.cf

    CONFDIR/spamassassin/local.cf

    CONFDIR/spamassassin.cf

    /etc/mail/sa-mailmunge.cf

    /etc/mail/spamassassin/sa-mailmunge.cf

    /etc/mail/spamassassin/local.cf

    /etc/mail/spamassassin.cf

where CONFDIR is the value of Mailmunge::Constants->get('Path:CONFDIR').

spam_assassin_status returns a Mail::SpamAssassin::PerMsgStatus object on success, or undef is something went wrong. Note that when you have finished using the returned status object, you should call its finish() method to free up resources.

AUTHOR

Dianne Skoll <dianne@skollsoft.com>

LICENSE

This code is licensed under the terms of the GNU General Public License, version 2.

Copyright © 2024 Skoll Software Consulting