line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2001-2019 by [Mark Overmeer]. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.02. |
5
|
|
|
|
|
|
|
# This code is part of distribution Mail-Transport. Meta-POD processed with |
6
|
|
|
|
|
|
|
# OODoc into POD and HTML manual-pages. See README.md |
7
|
|
|
|
|
|
|
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Mail::Transport; |
10
|
1
|
|
|
1
|
|
131549
|
use vars '$VERSION'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.004'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
6
|
use base 'Mail::Reporter'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
76
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
18
|
|
16
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
19
|
1
|
|
|
1
|
|
7
|
use File::Spec; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
445
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my %mailers = |
23
|
|
|
|
|
|
|
( exim => '::Exim' |
24
|
|
|
|
|
|
|
, imap => '::IMAP4' |
25
|
|
|
|
|
|
|
, imap4 => '::IMAP4' |
26
|
|
|
|
|
|
|
, mail => '::Mailx' |
27
|
|
|
|
|
|
|
, mailx => '::Mailx' |
28
|
|
|
|
|
|
|
, pop => '::POP3' |
29
|
|
|
|
|
|
|
, pop3 => '::POP3' |
30
|
|
|
|
|
|
|
, postfix => '::Sendmail' |
31
|
|
|
|
|
|
|
, qmail => '::Qmail' |
32
|
|
|
|
|
|
|
, sendmail => '::Sendmail' |
33
|
|
|
|
|
|
|
, smtp => '::SMTP' |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new(@) |
38
|
0
|
|
|
0
|
1
|
|
{ my $class = shift; |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
0
|
|
|
|
return $class->SUPER::new(@_) |
41
|
|
|
|
|
|
|
unless $class eq __PACKAGE__ || $class eq "Mail::Transport::Send"; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# |
44
|
|
|
|
|
|
|
# auto restart by creating the right transporter. |
45
|
|
|
|
|
|
|
# |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my %args = @_; |
48
|
0
|
0
|
0
|
|
|
|
my $via = lc($args{via} || '') |
49
|
|
|
|
|
|
|
or croak "No transport protocol provided"; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$via = 'Mail::Transport'.$mailers{$via} |
52
|
0
|
0
|
|
|
|
|
if exists $mailers{$via}; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
eval "require $via"; |
55
|
0
|
0
|
|
|
|
|
return undef if $@; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$via->new(@_); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub init($) |
61
|
0
|
|
|
0
|
0
|
|
{ my ($self, $args) = @_; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
$self->SUPER::init($args); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$self->{MT_hostname} |
66
|
0
|
0
|
|
|
|
|
= defined $args->{hostname} ? $args->{hostname} : 'localhost'; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
$self->{MT_port} = $args->{port}; |
69
|
0
|
|
|
|
|
|
$self->{MT_username} = $args->{username}; |
70
|
0
|
|
|
|
|
|
$self->{MT_password} = $args->{password}; |
71
|
0
|
|
0
|
|
|
|
$self->{MT_interval} = $args->{interval} || 30; |
72
|
0
|
|
0
|
|
|
|
$self->{MT_retry} = $args->{retry} || -1; |
73
|
0
|
|
0
|
|
|
|
$self->{MT_timeout} = $args->{timeout} || 120; |
74
|
0
|
|
|
|
|
|
$self->{MT_proxy} = $args->{proxy}; |
75
|
|
|
|
|
|
|
|
76
|
0
|
0
|
0
|
|
|
|
if(my $exec = $args->{executable} || $args->{proxy}) |
77
|
0
|
|
|
|
|
|
{ $self->{MT_exec} = $exec; |
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
$self->log(WARNING => "Avoid program abuse: specify an absolute path for $exec.") |
80
|
|
|
|
|
|
|
unless File::Spec->file_name_is_absolute($exec); |
81
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
unless(-x $exec) |
83
|
0
|
|
|
|
|
|
{ $self->log(WARNING => "Executable $exec does not exist."); |
84
|
0
|
|
|
|
|
|
return undef; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
$self; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#------------------------------------------ |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub remoteHost() |
94
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
95
|
0
|
|
|
|
|
|
@$self{ qw/MT_hostname MT_port MT_username MT_password/ }; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub retry() |
100
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
101
|
0
|
|
|
|
|
|
@$self{ qw/MT_interval MT_retry MT_timeout/ }; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my @safe_directories |
106
|
|
|
|
|
|
|
= qw(/usr/local/bin /usr/bin /bin /sbin /usr/sbin /usr/lib); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub findBinary($@) |
109
|
0
|
|
|
0
|
1
|
|
{ my ($self, $name) = (shift, shift); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
return $self->{MT_exec} |
112
|
0
|
0
|
|
|
|
|
if exists $self->{MT_exec}; |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
foreach (@_, @safe_directories) |
115
|
0
|
|
|
|
|
|
{ my $fullname = File::Spec->catfile($_, $name); |
116
|
0
|
0
|
|
|
|
|
return $fullname if -x $fullname; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
undef; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
#------------------------------------------ |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |