line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Mailer::smtp_auth;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
36234
|
use warnings;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
4
|
1
|
|
|
1
|
|
8
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
5
|
1
|
|
|
1
|
|
7
|
use vars qw(@ISA $VERSION);
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
65
|
|
6
|
1
|
|
|
1
|
|
949
|
use Net::SMTP_auth;
|
|
1
|
|
|
|
|
72823
|
|
|
1
|
|
|
|
|
55
|
|
7
|
1
|
|
|
1
|
|
762
|
use Mail::Util qw(mailaddress);
|
|
1
|
|
|
|
|
3739
|
|
|
1
|
|
|
|
|
2345
|
|
8
|
1
|
|
|
1
|
|
186
|
use Carp;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1551
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$VERSION = '0.02';
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require Mail::Mailer::rfc822;
|
13
|
|
|
|
|
|
|
@ISA = qw(Mail::Mailer::rfc822);
|
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
0
|
0
|
|
sub can_cc { 0 }
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub exec {
|
18
|
0
|
|
|
0
|
0
|
|
my($self, $exe, $args, $to) = @_;
|
19
|
0
|
|
|
|
|
|
my %opt = @$args;
|
20
|
0
|
|
0
|
|
|
|
my $host = $opt{Server} || undef;
|
21
|
0
|
|
0
|
|
|
|
$opt{Debug} ||= 0;
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# for Net::SMTP_auth we do not really exec
|
24
|
0
|
0
|
|
|
|
|
my $smtp = Net::SMTP_auth->new($host, %opt)
|
25
|
|
|
|
|
|
|
or return undef;
|
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
if ($opt{Auth}) {
|
28
|
0
|
0
|
|
|
|
|
$smtp->auth(@{$opt{Auth}})
|
|
0
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
or return undef;
|
30
|
|
|
|
|
|
|
}
|
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
${*$self}{'sock'} = $smtp;
|
|
0
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
$smtp->mail(mailaddress());
|
35
|
0
|
|
|
|
|
|
my $u;
|
36
|
0
|
|
|
|
|
|
foreach $u (@$to) {
|
37
|
0
|
|
|
|
|
|
$smtp->to($u);
|
38
|
|
|
|
|
|
|
}
|
39
|
0
|
|
|
|
|
|
$smtp->data;
|
40
|
0
|
0
|
|
|
|
|
untie(*$self) if tied *$self;
|
41
|
0
|
|
|
|
|
|
tie *$self, 'Mail::Mailer::smtp_auth::pipe',$self;
|
42
|
0
|
|
|
|
|
|
$self;
|
43
|
|
|
|
|
|
|
}
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub set_headers {
|
46
|
0
|
|
|
0
|
0
|
|
my($self,$hdrs) = @_;
|
47
|
0
|
|
|
|
|
|
$self->SUPER::set_headers({
|
48
|
|
|
|
|
|
|
From => "<" . mailaddress() . ">",
|
49
|
|
|
|
|
|
|
%$hdrs,
|
50
|
|
|
|
|
|
|
'X-Mailer' => "Mail::Mailer[v$Mail::Mailer::VERSION] Net::SMTP_auth[v$Net::SMTP_auth::VERSION]"
|
51
|
|
|
|
|
|
|
})
|
52
|
|
|
|
|
|
|
}
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub epilogue {
|
55
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
56
|
0
|
|
|
|
|
|
my $sock = ${*$self}{'sock'};
|
|
0
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$sock->dataend;
|
58
|
0
|
|
|
|
|
|
$sock->quit;
|
59
|
0
|
|
|
|
|
|
delete ${*$self}{'sock'};
|
|
0
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
untie(*$self);
|
61
|
|
|
|
|
|
|
}
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub close {
|
64
|
0
|
|
|
0
|
0
|
|
my($self, @to) = @_;
|
65
|
0
|
|
|
|
|
|
my $sock = ${*$self}{'sock'};
|
|
0
|
|
|
|
|
|
|
66
|
0
|
0
|
0
|
|
|
|
if ($sock && fileno($sock)) {
|
67
|
0
|
|
|
|
|
|
$self->epilogue;
|
68
|
|
|
|
|
|
|
# Epilogue should destroy the SMTP filehandle,
|
69
|
|
|
|
|
|
|
# but just to be on the safe side.
|
70
|
0
|
0
|
0
|
|
|
|
if ($sock && fileno($sock)) {
|
71
|
0
|
0
|
|
|
|
|
close $sock
|
72
|
|
|
|
|
|
|
or croak 'Cannot destroy socket filehandle';
|
73
|
|
|
|
|
|
|
}
|
74
|
|
|
|
|
|
|
}
|
75
|
0
|
|
|
|
|
|
1;
|
76
|
|
|
|
|
|
|
}
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
package Mail::Mailer::smtp_auth::pipe;
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub TIEHANDLE {
|
81
|
0
|
|
|
0
|
|
|
my $pkg = shift;
|
82
|
0
|
|
|
|
|
|
my $self = shift;
|
83
|
0
|
|
|
|
|
|
my $sock = ${*$self}{'sock'};
|
|
0
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
return bless \$sock;
|
85
|
|
|
|
|
|
|
}
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub PRINT {
|
88
|
0
|
|
|
0
|
|
|
my $self = shift;
|
89
|
0
|
|
|
|
|
|
my $sock = $$self;
|
90
|
0
|
|
|
|
|
|
$sock->datasend( @_ );
|
91
|
|
|
|
|
|
|
}
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__
|