line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Server::Mail::ESMTP::SIZE; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
37151
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
83
|
|
4
|
2
|
|
|
2
|
|
11
|
use base qw(Net::Server::Mail::ESMTP::Extension); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
2110
|
|
5
|
2
|
|
|
2
|
|
829
|
use vars qw($VERSION); |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
976
|
|
6
|
|
|
|
|
|
|
$VERSION = '0.02'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub init { |
9
|
1
|
|
|
1
|
0
|
27
|
my ($self, $parent) = @_; |
10
|
1
|
|
|
|
|
9
|
$self->{parent} = $parent; |
11
|
1
|
|
|
|
|
4
|
return $self; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub reply { |
15
|
0
|
|
|
0
|
0
|
|
return (['DATA' => \&reply_mail_body], |
16
|
|
|
|
|
|
|
['MAIL' => \&reply_mail_from]); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub option { |
20
|
0
|
|
|
0
|
0
|
|
return (['MAIL', 'SIZE' => \&option_mail_size]); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub option_mail_size { |
24
|
0
|
|
|
0
|
0
|
|
my ($self, $command, $mail_from, $option, $value) = @_; |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
if (lc($option) eq 'size'){ |
27
|
0
|
0
|
|
|
|
|
if ($value <= $self->{'_size_extension'}){ |
28
|
0
|
|
|
|
|
|
$self->{'_size_option_result'} = [ 200, 'OK' ]; |
29
|
|
|
|
|
|
|
} else { |
30
|
0
|
|
|
|
|
|
$self->{'_size_option_result'} = [ '552', 'message size exceeds fixed maximium message size' ]; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub reply_mail_from { |
36
|
0
|
|
|
0
|
0
|
|
my ($self, $command, $last, $code, $message) = @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
if (defined ($self->{'_size_option_result'})){ |
39
|
0
|
|
|
|
|
|
return @{ $self->{'_size_option_result'} }; |
|
0
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub reply_mail_body { |
44
|
0
|
|
|
0
|
0
|
|
my ($self, $command, $last, $code, $message) = @_; |
45
|
0
|
0
|
|
|
|
|
if (length($self->{'_data'}) <= $self->{'_size_extension'}){ |
46
|
0
|
|
|
|
|
|
return ($code, $message); |
47
|
|
|
|
|
|
|
} else { |
48
|
0
|
|
|
|
|
|
return (552, 'Message too big!'); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub keyword { |
53
|
0
|
|
|
0
|
0
|
|
return 'SIZE'; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub set_size { |
57
|
0
|
|
|
0
|
1
|
|
my ($self, $size) = @_; |
58
|
0
|
|
|
|
|
|
$self->{'_size_extension'} = $size; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
*Net::Server::Mail::ESMTP::set_size = \&set_size; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub parameter { |
64
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
65
|
0
|
|
|
|
|
|
return $self->{'parent'}->{'_size_extension'}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#################### main pod documentation begin ################### |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Net::Server::Mail::ESMTP::SIZE - add support for the SIZE ESMTP extension to Net::Server::Mail |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SYNOPSIS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
use Net::Server::Mail::ESMTP; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my @local_domains = qw(example.com example.org); |
81
|
|
|
|
|
|
|
my $server = new IO::Socket::INET Listen => 1, LocalPort => 25; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $conn; |
84
|
|
|
|
|
|
|
while($conn = $server->accept) |
85
|
|
|
|
|
|
|
{ |
86
|
|
|
|
|
|
|
my $esmtp = new Net::Server::Mail::ESMTP socket => $conn; |
87
|
|
|
|
|
|
|
# activate some extensions |
88
|
|
|
|
|
|
|
$esmtp->register('Net::Server::Mail::ESMTP::SIZE'); |
89
|
|
|
|
|
|
|
$esmtp->set_size(10_000_000); #10 Milion bytes |
90
|
|
|
|
|
|
|
$esmtp->process(); |
91
|
|
|
|
|
|
|
$conn->close() |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 DESCRIPTION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Add the ESMTP SIZE extension to Net::Server::Mail::ESMTP. I stubbed this extension |
97
|
|
|
|
|
|
|
when I wrote Test::SMTP and thought it would be nice to finish it off. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 METHODS |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=over |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item set_size($size) |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Establishes the size threshold for rejecting messages. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=back |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 USAGE |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Register the plugin in the ESMTP object, and then call set_size on the object instance |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Jose Luis Martinez |
116
|
|
|
|
|
|
|
CPAN ID: JLMARTIN |
117
|
|
|
|
|
|
|
CAPSiDE |
118
|
|
|
|
|
|
|
jlmartinez@capside.com |
119
|
|
|
|
|
|
|
http://www.pplusdomain.net |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 COPYRIGHT |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This program is free software; you can redistribute |
124
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The full text of the license can be found in the |
127
|
|
|
|
|
|
|
LICENSE file included with this module. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 SEE ALSO |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Net::Server::Mail, Net::Server::Mail::ESMTP |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
#################### main pod documentation end ################### |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |