line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2001-2018 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
|
|
149093
|
use vars '$VERSION'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
90
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.003'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
7
|
use base 'Mail::Reporter'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
136
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
16
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
94
|
|
19
|
1
|
|
|
1
|
|
5
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
836
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my %mailers = |
23
|
|
|
|
|
|
|
( exim => '::Exim' |
24
|
|
|
|
|
|
|
, mail => '::Mailx' |
25
|
|
|
|
|
|
|
, mailx => '::Mailx' |
26
|
|
|
|
|
|
|
, pop => '::POP3' |
27
|
|
|
|
|
|
|
, pop3 => '::POP3' |
28
|
|
|
|
|
|
|
, postfix => '::Sendmail' |
29
|
|
|
|
|
|
|
, qmail => '::Qmail' |
30
|
|
|
|
|
|
|
, sendmail => '::Sendmail' |
31
|
|
|
|
|
|
|
, smtp => '::SMTP' |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new(@) |
36
|
0
|
|
|
0
|
1
|
|
{ my $class = shift; |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
0
|
|
|
|
return $class->SUPER::new(@_) |
39
|
|
|
|
|
|
|
unless $class eq __PACKAGE__ || $class eq "Mail::Transport::Send"; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# |
42
|
|
|
|
|
|
|
# auto restart by creating the right transporter. |
43
|
|
|
|
|
|
|
# |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my %args = @_; |
46
|
0
|
0
|
0
|
|
|
|
my $via = lc($args{via} || '') |
47
|
|
|
|
|
|
|
or croak "No transport protocol provided"; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$via = 'Mail::Transport'.$mailers{$via} |
50
|
0
|
0
|
|
|
|
|
if exists $mailers{$via}; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
eval "require $via"; |
53
|
0
|
0
|
|
|
|
|
return undef if $@; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$via->new(@_); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub init($) |
59
|
0
|
|
|
0
|
0
|
|
{ my ($self, $args) = @_; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$self->SUPER::init($args); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$self->{MT_hostname} |
64
|
0
|
0
|
|
|
|
|
= defined $args->{hostname} ? $args->{hostname} : 'localhost'; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$self->{MT_port} = $args->{port}; |
67
|
0
|
|
|
|
|
|
$self->{MT_username} = $args->{username}; |
68
|
0
|
|
|
|
|
|
$self->{MT_password} = $args->{password}; |
69
|
0
|
|
0
|
|
|
|
$self->{MT_interval} = $args->{interval} || 30; |
70
|
0
|
|
0
|
|
|
|
$self->{MT_retry} = $args->{retry} || -1; |
71
|
0
|
|
0
|
|
|
|
$self->{MT_timeout} = $args->{timeout} || 120; |
72
|
0
|
|
|
|
|
|
$self->{MT_proxy} = $args->{proxy}; |
73
|
|
|
|
|
|
|
|
74
|
0
|
0
|
0
|
|
|
|
if(my $exec = $args->{executable} || $args->{proxy}) |
75
|
0
|
|
|
|
|
|
{ $self->{MT_exec} = $exec; |
76
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
$self->log(WARNING => "Avoid program abuse: specify an absolute path for $exec.") |
78
|
|
|
|
|
|
|
unless File::Spec->file_name_is_absolute($exec); |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
unless(-x $exec) |
81
|
0
|
|
|
|
|
|
{ $self->log(WARNING => "Executable $exec does not exist."); |
82
|
0
|
|
|
|
|
|
return undef; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
$self; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
#------------------------------------------ |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub remoteHost() |
92
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
93
|
0
|
|
|
|
|
|
@$self{ qw/MT_hostname MT_port MT_username MT_password/ }; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub retry() |
98
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
99
|
0
|
|
|
|
|
|
@$self{ qw/MT_interval MT_retry MT_timeout/ }; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
my @safe_directories |
104
|
|
|
|
|
|
|
= qw(/usr/local/bin /usr/bin /bin /sbin /usr/sbin /usr/lib); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub findBinary($@) |
107
|
0
|
|
|
0
|
1
|
|
{ my ($self, $name) = (shift, shift); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
return $self->{MT_exec} |
110
|
0
|
0
|
|
|
|
|
if exists $self->{MT_exec}; |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
foreach (@_, @safe_directories) |
113
|
0
|
|
|
|
|
|
{ my $fullname = File::Spec->catfile($_, $name); |
114
|
0
|
0
|
|
|
|
|
return $fullname if -x $fullname; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
undef; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
#------------------------------------------ |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |