line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::MtPolicyd::Plugin::AddScoreHeader; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
2392
|
use Moose; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
16
|
|
4
|
2
|
|
|
2
|
|
12152
|
use namespace::autoclean; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
22
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '2.02'; # VERSION |
7
|
|
|
|
|
|
|
# ABSTRACT: mtpolicyd plugin for adding the score as header to the mail |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
extends 'Mail::MtPolicyd::Plugin'; |
10
|
|
|
|
|
|
|
with 'Mail::MtPolicyd::Plugin::Role::Scoring'; |
11
|
|
|
|
|
|
|
with 'Mail::MtPolicyd::Plugin::Role::UserConfig' => { |
12
|
|
|
|
|
|
|
'uc_attributes' => [ 'spam_score' ], |
13
|
|
|
|
|
|
|
}; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
282
|
use Mail::MtPolicyd::Plugin::Result; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
530
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has 'header_name' => ( |
19
|
|
|
|
|
|
|
is => 'ro', isa => 'Str', |
20
|
|
|
|
|
|
|
default => 'X-MtScore', |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has 'spam_score' => ( is => 'ro', isa => 'Num', default => '5' ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub run { |
26
|
1
|
|
|
1
|
1
|
343
|
my ( $self, $r ) = @_; |
27
|
1
|
|
|
|
|
3
|
my $score = $self->_get_score($r); |
28
|
1
|
|
|
|
|
23
|
my $spam_score = $self->get_uc($r->session, 'spam_score'); |
29
|
1
|
|
|
|
|
1
|
my $value; |
30
|
1
|
50
|
|
|
|
16
|
if( ! defined $score ) { |
31
|
0
|
|
|
|
|
0
|
$self->log($r, 'score is undefined'); |
32
|
|
|
|
|
|
|
} |
33
|
1
|
50
|
|
|
|
4
|
if( $score >= $spam_score ) { |
34
|
1
|
|
|
|
|
1
|
$value = 'YES '; |
35
|
|
|
|
|
|
|
} else { |
36
|
0
|
|
|
|
|
0
|
$value = 'NO '; |
37
|
|
|
|
|
|
|
} |
38
|
1
|
|
|
|
|
2
|
$value .= 'score='.$score; |
39
|
1
|
50
|
|
|
|
4
|
if( my $details = $self->_get_score_detail($r) ) { |
40
|
1
|
|
|
|
|
3
|
$value .= ' ['.$details.']'; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
26
|
return Mail::MtPolicyd::Plugin::Result->new_header_once( |
44
|
|
|
|
|
|
|
$r->is_already_done('score-'.$self->score_field.'-tag'), |
45
|
|
|
|
|
|
|
$self->header_name, $value ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=pod |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=encoding UTF-8 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Mail::MtPolicyd::Plugin::AddScoreHeader - mtpolicyd plugin for adding the score as header to the mail |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 VERSION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
version 2.02 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 DESCRIPTION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Adds an header with the current score and score details to the mail. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 PARAMETERS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=over |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item (uc_)spam_score (default: 5) |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
If the score is higher than this value it'll be tagged as 'YES'. |
77
|
|
|
|
|
|
|
Otherwise 'NO'. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item score_field (default: score) |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Specifies the name of the field the score is stored in. |
82
|
|
|
|
|
|
|
Could be set if you need multiple scores. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item header_name (default: X-MtScore) |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
The name of the header to set. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=back |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 EXAMPLE |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
<Plugin add-score-header> |
93
|
|
|
|
|
|
|
module = "AddScoreHeader" |
94
|
|
|
|
|
|
|
# score_field = "score" |
95
|
|
|
|
|
|
|
# header_name = "X-MtScore" |
96
|
|
|
|
|
|
|
spam_score = 5 |
97
|
|
|
|
|
|
|
</Plugin> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Will return an action like: |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
X-MtScore: YES score=7.5 [CTIPREP_TEMP=2.5, spamhaus-rbl=5] |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This is free software, licensed under: |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |