line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
929
|
use 5.014; |
|
1
|
|
|
|
|
4
|
|
2
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
48
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Mail::Qmail::Filter::ValidateSender; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.0'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Mo qw(coerce default); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
9
|
|
|
|
|
|
|
extends 'Mail::Qmail::Filter'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has 'params' => {}; |
12
|
|
|
|
|
|
|
has 'reject_text' => 'Invalid sender address.'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub filter { |
15
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
16
|
0
|
0
|
|
|
|
|
length( my $mail_from = $self->message->from ) or return; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
require Email::Valid; |
19
|
|
|
|
|
|
|
$self->reject( $self->reject_text, $mail_from ) |
20
|
0
|
0
|
|
|
|
|
unless Email::Valid->new( %{ $self->params } )->address($mail_from); |
|
0
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
1; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
__END__ |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 NAME |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Mail::Qmail::Filter::ValidateFrom - |
30
|
|
|
|
|
|
|
check syntax of RFC5321.MailFrom address |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 SYNOPSIS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
use Mail::Qmail::Filter; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Mail::Qmail::Filter->new->add_filters( |
37
|
|
|
|
|
|
|
'::ValidateSender' => { |
38
|
|
|
|
|
|
|
skip_for_rcpt => [ 'postmaster', 'postmaster@' . $mydomain ], |
39
|
|
|
|
|
|
|
params => { '-mxcheck' => 1 }, |
40
|
|
|
|
|
|
|
}, |
41
|
|
|
|
|
|
|
'::Queue', |
42
|
|
|
|
|
|
|
)->run; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 DESCRIPTION |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
This L<Mail::Qmail::Filter> plugin checks if the RFC5321.MailFrom aka the |
47
|
|
|
|
|
|
|
envelope sender of the message contains a valid e-mail address (as far as |
48
|
|
|
|
|
|
|
L<Email::Valid> can tell). |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Please note that empty sender addresses (as used for bounce messages) |
51
|
|
|
|
|
|
|
count as valid. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 OPTIONAL PARAMETERS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 params |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
reference to a hash of parameters to pass to L<Email::Valid> |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 reject_text |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Text to use when rejecting the message because it has an invalid sender address. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
May be a string or a subroutine which returns the text. |
64
|
|
|
|
|
|
|
The subroutine may access the problematic address as its first argument. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Default: "Invalid sender address." |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SEE ALSO |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
L<Mail::Qmail::Filter/COMMON PARAMETERS FOR ALL FILTERS>, L<Email::Valid> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Copyright 2019 Martin Sluka. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it |
77
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
78
|
|
|
|
|
|
|
copy of the full license at: |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
L<http://www.perlfoundation.org/artistic_license_2_0> |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
83
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
84
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
85
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
88
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
89
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
92
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
95
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
96
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
97
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
98
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
99
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
100
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
101
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
104
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
105
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
106
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
107
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
108
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
109
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
110
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |