| 1 | 1 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | package Mail::Qmail::Filter::SpamAssassin; | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '1.01'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Mo qw(coerce default); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | extends 'Mail::Qmail::Filter'; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | has 'dump_spam_to'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | has 'mark'; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | has 'reject_score'; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | has 'reject_text' => 'I think this message is spam.'; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my $message = $self->message; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | my $body_ref = $message->body_ref; | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | require Mail::SpamAssassin; # lazy load because filter might be skipped | |||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my $sa = Mail::SpamAssassin->new; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my $mail = $sa->parse($body_ref); | |||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | my $status = $sa->check($mail); | |||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | $self->debug( 'spam score' => my $score = $status->get_score ); | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if ( $status->is_spam ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if ( defined( my $dir = $self->dump_spam_to ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | require Path::Tiny and Path::Tiny->import('path') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined &Mail::Qmail::Filter::SpamAssassin::path || require Path::Tiny && 'Path::Tiny'->import('path')
require Path::Tiny and "Path::Tiny"->import("path")
MC/DC0%0/3
defined &Mail::Qmail::Filter::SpamAssassin::path || require Path::Tiny && 'Path::Tiny'->import('path')
defined &Mail::Qmail::Filter::SpamAssassin::path
require Path::Tiny
"Path::Tiny"->import("path")
Truth table0%0/4
A || B and C
A= defined &Mail::Qmail::Filter::SpamAssassin::pathB= require Path::TinyC= "Path::Tiny"->import("path")
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | unless defined &path; | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | path( $dir, my $file = join '_', $^T, $$, $score ) | |||||||||||||||||||||||||||||||||||||||||
| 32 | ->spew($$body_ref); | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $self->debug( 'dumped message to' => $file ); | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | path( $dir, $file . '_report' )->spew( $status->get_report ); | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | $self->reject( $self->reject_text ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->reject_score and $score >= $self->reject_score
MC/DC0%0/2
$self->reject_score and $score >= $self->reject_score
$self->reject_score
$score >= $self->reject_score
Truth table0%0/3
A and B
A= $self->reject_scoreB= $score >= $self->reject_score
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | if $self->reject_score && $score >= $self->reject_score; | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | $$body_ref = $status->rewrite_mail if $self->mark; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | __END__ | ||||||||||||||||||||||||||||||||||||||||||