Mail::Audit::Razor - Mail::Audit plugin for the Vipul's Razor spam detection system


Mail-Audit-Razor documentation Contained in the Mail-Audit-Razor distribution.

Index


Code Index:

NAME

Top

Mail::Audit::Razor - Mail::Audit plugin for the Vipul's Razor spam detection system

SYNOPSIS

Top

    use Mail::Audit qw(Razor);
        my $mail = Mail::Audit->new;
    ...
        $mail->spam_accept($spambox);
        $mail->accept;

DESCRIPTION

Top

This is a Mail::Audit plugin that uses the Vipul's Razor distributed spam detection system to detect and deal with spam. It requires the Razor::Client and Razor::Agent modules from http://razor.sourceforge.net.

While Razor never flags false positives, it has been having problems with false reporting. Until that gets fixed I'd advise against ignoring or rejecting spam with this module.

METHODS

spam_accept($where)

Calls accept and returns 1 if the message is spam, otherwise 0.

spam_ignore

Calls ignore and returns 1 if the message is spam, otherwise 0.

spam_reject($reason)

Calls reject and returns 1 if the message is spam, otherwise 0.

spam_pipe($program)

Calls pipe and returns 1 if the message is spam, otherwise 0.

is_spam

Returns 1 if the message is spam, 0 if it is not.

VARIABLES

$Mail::Audit::Razor::config

The path to your razor config file. The default is $ENV{HOME}/razor.conf.

AUTHOR

Top

Nate Mueller <nate@cs.wisc.edu>

SEE ALSO

Top

http://razor.sourceforge.net and Mail::Audit


Mail-Audit-Razor documentation Contained in the Mail-Audit-Razor distribution.

package Mail::Audit::Razor;
use Mail::Audit;
use vars qw(@VERSION $config);
$VERSION = '1.802';
1;

package Mail::Audit;

use strict;
use Razor::Client;
use Razor::Agent;
use Razor::String qw(hash);

sub is_spam {
  my ($self) = @_;

  my @message = (split("\n", $self->header), "", "", @{ $self->body });

  my $razor
    = new Razor::Agent($Mail::Audit::Razor::config || "$ENV{HOME}/razor.conf");
  my $response = $razor->check(sigs => [ hash(\@message) ])
    || $razor->raise_error();

  return $response->[0];
}

sub spam_handle {
  my ($self, $data, $action) = @_;

  if ($self->is_spam) {
    $self->accept($data)
      if ($action eq "accept");
    $self->ignore()
      if ($action eq "ignore");
    $self->reject($data)
      if ($action eq "reject");
    $self->pipe($data)
      if ($action eq "pipe");

    return 1;
  }

  return 0;
}

sub spam_accept {
  &spam_handle(@_[ 0, 1 ], "accept");
}

sub spam_ignore {
  &spam_handle(@_[ 0, 1 ], "ignore");
}

sub spam_reject {
  &spam_handle(@_[ 0, 1 ], "reject");
}

sub spam_pipe {
  &spam_handle(@_[ 0, 1 ], "pipe");
}

1;
__END__