| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Async::SMTP::Connection; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
239078
|
use strict; |
|
|
2
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
117
|
|
|
4
|
2
|
|
|
2
|
|
15
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
177
|
|
|
5
|
2
|
|
|
2
|
|
22
|
use parent qw(IO::Async::Stream); |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
25
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.004'; ## VERSION |
|
8
|
|
|
|
|
|
|
## AUTHORITY |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Net::Async::SMTP::Connection - stream subclass for dealing with SMTP connections |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Used internally by L. No user-serviceable parts inside. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Timeouts: |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
RFC821 4.5.3.2 - An SMTP client MUST provide a timeout mechanism |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
greeting_timeout => 300, |
|
23
|
|
|
|
|
|
|
mail_timeout => 300, |
|
24
|
|
|
|
|
|
|
rcpt_timeout => 300, |
|
25
|
|
|
|
|
|
|
data_timeout => 120, |
|
26
|
|
|
|
|
|
|
data_block_timeout => 180, |
|
27
|
|
|
|
|
|
|
data_finish_timeout => 600, |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
|
30
|
|
|
|
|
|
|
|
|
31
|
2
|
|
|
2
|
|
102521
|
use IO::Socket::SSL qw(SSL_VERIFY_NONE); |
|
|
2
|
|
|
|
|
185256
|
|
|
|
2
|
|
|
|
|
55
|
|
|
32
|
2
|
|
|
2
|
|
1827
|
use Protocol::SMTP::Client; |
|
|
2
|
|
|
|
|
19959
|
|
|
|
2
|
|
|
|
|
1756
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub configure { |
|
35
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
36
|
0
|
|
|
|
|
|
my %args = @_; |
|
37
|
0
|
0
|
|
|
|
|
$self->{auth} = delete $args{auth} if exists $args{auth}; |
|
38
|
0
|
|
|
|
|
|
$self->SUPER::configure(%args) |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _add_to_loop { |
|
42
|
0
|
|
|
0
|
|
|
my ($self, $loop) = @_; |
|
43
|
|
|
|
|
|
|
$self->{protocol} = Protocol::SMTP::Client->new( |
|
44
|
0
|
|
|
0
|
|
|
future_factory => sub { $loop->new_future }, |
|
45
|
0
|
|
|
0
|
|
|
writer => sub { $self->write(@_) }, |
|
46
|
0
|
|
|
|
|
|
auth_mechanism_override => $self->auth, |
|
47
|
|
|
|
|
|
|
); |
|
48
|
0
|
|
|
|
|
|
$self->protocol->startup; |
|
49
|
0
|
|
|
|
|
|
$self->SUPER::_add_to_loop($loop); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _remove_from_loop { |
|
53
|
0
|
|
|
0
|
|
|
my ($self, $loop) = @_; |
|
54
|
0
|
|
|
|
|
|
delete $self->{protocol}; |
|
55
|
0
|
|
|
|
|
|
$self->SUPER::_remove_from_loop($loop); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
0
|
0
|
|
sub auth { shift->{auth} } |
|
59
|
0
|
|
|
0
|
0
|
|
sub protocol { shift->{protocol} } |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub send_greeting { |
|
62
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
63
|
|
|
|
|
|
|
# Start with our greeting, which should receive back a nice list of features |
|
64
|
0
|
|
|
|
|
|
$self->protocol->send_greeting; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub starttls { |
|
68
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
69
|
0
|
|
|
|
|
|
my %args = @_; |
|
70
|
0
|
|
|
|
|
|
$self->debug_printf("STARTTLS"); |
|
71
|
0
|
0
|
|
|
|
|
die "This server does not support TLS" unless $self->has_feature('STARTTLS'); |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
require IO::Async::SSL; |
|
74
|
|
|
|
|
|
|
$self->protocol->starttls->then(sub { |
|
75
|
|
|
|
|
|
|
$self->loop->SSL_upgrade( |
|
76
|
|
|
|
|
|
|
handle => $self, |
|
77
|
|
|
|
|
|
|
# SSL_verify_mode => SSL_VERIFY_NONE, |
|
78
|
|
|
|
|
|
|
%args, |
|
79
|
|
|
|
|
|
|
)->on_done(sub { |
|
80
|
0
|
|
|
|
|
|
$self->debug_printf("STARTTLS successful"); |
|
81
|
|
|
|
|
|
|
}) |
|
82
|
|
|
|
|
|
|
->then($self->curry::send_greeting) |
|
83
|
0
|
|
|
0
|
|
|
->transform(done => sub { $self }); |
|
|
0
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
}); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub on_read { |
|
88
|
0
|
|
|
0
|
1
|
|
my ($self, $buffref) = @_; |
|
89
|
0
|
|
|
|
|
|
while( $$buffref =~ s/^(.*)\x0D\x0A// ) { |
|
90
|
0
|
|
|
|
|
|
my $line = $1; |
|
91
|
0
|
0
|
|
|
|
|
if($self->{sending_content}) { |
|
92
|
0
|
|
|
|
|
|
warn "- this is awkward; we shouldn't have anything because we're in the middle of sending: $1"; |
|
93
|
|
|
|
|
|
|
} else { |
|
94
|
0
|
|
|
|
|
|
$self->protocol->handle_line($line); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
} |
|
97
|
0
|
|
|
|
|
|
return 0; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
0
|
|
|
0
|
0
|
|
sub has_feature { my $self = shift; $self->protocol->has_feature(@_) } |
|
|
0
|
|
|
|
|
|
|
|
101
|
0
|
|
|
0
|
0
|
|
sub send { my $self = shift; $self->protocol->send(@_) } |
|
|
0
|
|
|
|
|
|
|
|
102
|
0
|
|
|
0
|
0
|
|
sub login { my $self = shift; $self->protocol->login(@_) } |
|
|
0
|
|
|
|
|
|
|
|
103
|
0
|
|
|
0
|
0
|
|
sub quit { my $self = shift; $self->protocol->quit(@_) } |
|
|
0
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 AUTHOR |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Tom Molesworth |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 LICENSE |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Copyright Tom Molesworth 2012-2024. Licensed under the same terms as Perl itself. |
|
114
|
|
|
|
|
|
|
|