Transport.pm

filter: Statementstmt 38.6% 22 / 57 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 54.5% 6 / 11 Podpod 80.0% 4 / 5 totaltotal 27.8% 32 / 115 SCAR 50.7
CC
18
Cov
24%
init
90.0
new
56.0
findBinary
20.0
CRAP 159.2
« Transport/Send.pm ↑ Summary Transport/Mailx.pm »
1 # Copyrights 2001-2020 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 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 $VERSION = '3.005';
12  
13 1 ▶use base 'Mail::Reporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21  
22 1 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 ▶{ my $class = shift;
Subroutine new: not called CC=7 SCAR=40.3
Pod documented
39  
40 0 ▶ return $class->SUPER::new(@_)
Branch: 1 branch
BranchTrueFalseTotal
unless $class eq __PACKAGE__ or $class eq "Mail::Transport::Send" 0 0 0
Condition0%0/3
$class eq __PACKAGE__ or $class eq "Mail::Transport::Send"
l!l&&r!l&&!r
000
MC/DC0%0/2
$class eq __PACKAGE__ or $class eq "Mail::Transport::Send"
$class eq __PACKAGE__ $class eq "Mail::Transport::Send"
Truth table0%0/3
A or B
A= $class eq __PACKAGE__B= $class eq "Mail::Transport::Send"
ABresult
1X1
011
000
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 ▶ my $via = lc($args{via} || '')
Branch: 1 branch
BranchTrueFalseTotal
my $via = lc($args{"via"} || "") or croak("No transport protocol provided") 0 0 0
Condition0%0/2
$args{'via'} || ''
l!l
00
MC/DC0%0/1
$args{'via'} || ''
$args{'via'}
Truth table0%0/2
A
A= $args{'via'}
Aresult
11
00
49 or croak "No transport protocol provided";
50  
51 $via = 'Mail::Transport'.$mailers{$via}
52 0 ▶ if exists $mailers{$via};
Branch: 1 branch
BranchTrueFalseTotal
if exists $mailers{$via} 0 0 0
53  
54 0 eval "require $via";
55 0 ▶ return undef if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
56  
57 0 $via->new(@_);
58 }
59  
60 sub init($)
61 0 ▶{ my ($self, $args) = @_;
Subroutine init: not called CC=9 SCAR=45.0
Pod undocumented
62  
63 0 $self->SUPER::init($args);
64  
65 $self->{MT_hostname}
66 0 ▶ = defined $args->{hostname} ? $args->{hostname} : 'localhost';
Branch: 1 branch
BranchTrueFalseTotal
defined $args->{'hostname'} ? : 0 0 0
67  
68 0 $self->{MT_port} = $args->{port};
69 0 $self->{MT_username} = $args->{username};
70 0 $self->{MT_password} = $args->{password};
71 0 ▶ $self->{MT_interval} = $args->{interval} || 30;
Condition0%0/2
$args->{'interval'} || 30
l!l
00
MC/DC0%0/1
$args->{'interval'} || 30
$args->{'interval'}
Truth table0%0/2
A
A= $args->{'interval'}
Aresult
11
00
72 0 ▶ $self->{MT_retry} = $args->{retry} || -1;
Condition0%0/2
$args->{'retry'} || -1
l!l
00
MC/DC0%0/1
$args->{'retry'} || -1
$args->{'retry'}
Truth table0%0/2
A
A= $args->{'retry'}
Aresult
11
00
73 0 ▶ $self->{MT_timeout} = $args->{timeout} || 120;
Condition0%0/2
$args->{'timeout'} || 120
l!l
00
MC/DC0%0/1
$args->{'timeout'} || 120
$args->{'timeout'}
Truth table0%0/2
A
A= $args->{'timeout'}
Aresult
11
00
74 0 $self->{MT_proxy} = $args->{proxy};
75  
76 0 ▶ if(my $exec = $args->{executable} || $args->{proxy})
Branch: 1 branch
BranchTrueFalseTotal
if (my $exec = $args->{"executable"} || $args->{"proxy"}) 0 0 0
Condition0%0/3
$args->{'executable'} || $args->{'proxy'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->{'executable'} || $args->{'proxy'}
$args->{'executable'} $args->{'proxy'}
Truth table0%0/3
A || B
A= $args->{'executable'}B= $args->{'proxy'}
ABresult
1X1
011
000
77 0 { $self->{MT_exec} = $exec;
78  
79 0 ▶ $self->log(WARNING => "Avoid program abuse: specify an absolute path for $exec.")
Branch: 1 branch
BranchTrueFalseTotal
unless "File::Spec"->file_name_is_absolute($exec) 0 0 0
80 unless File::Spec->file_name_is_absolute($exec);
81  
82 0 ▶ unless(-x $exec)
Branch: 1 branch
BranchTrueFalseTotal
unless (-x $exec) 0 0 0
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 ▶{ my $self = shift;
Subroutine remoteHost: not called CC=1 SCAR=6.9
Pod documented
95 0 @$self{ qw/MT_hostname MT_port MT_username MT_password/ };
96 }
97  
98  
99 sub retry()
100 0 ▶{ my $self = shift;
Subroutine retry: not called CC=1 SCAR=6.9
Pod documented
101 0 @$self{ qw/MT_interval MT_retry MT_timeout/ };
102 }
103  
104  
105 my @safe_directories
106 1 = qw(/usr/local/bin /usr/bin /bin /sbin /usr/sbin /usr/lib);
107  
108 sub findBinary($@)
109 0 ▶{ my ($self, $name) = (shift, shift);
Subroutine findBinary: not called CC=4 SCAR=30.0
Pod documented
110  
111 return $self->{MT_exec}
112 0 ▶ if exists $self->{MT_exec};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"MT_exec"} 0 0 0
113  
114 0 foreach (@_, @safe_directories)
115 0 { my $fullname = File::Spec->catfile($_, $name);
116 0 ▶ return $fullname if -x $fullname;
Branch: 1 branch
BranchTrueFalseTotal
if -x $fullname 0 0 0
117 }
118  
119 0 undef;
120 }
121  
122 #------------------------------------------
123  
124 1 1;
« Transport/Send.pm ↑ Summary Transport/Mailx.pm »