Transport.pm

filter: Statementstmt 38.4% 20 / 52 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 16 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 50.0% 5 / 10 Podpod 80.0% 4 / 5 totaltotal 26.3% 29 / 110 CC 18 SCAR 38.7
CC
18
Cov
23%
init
90.0
new
56.0
findBinary
20.0
CRAP 47.8
« Transport/Send.pm ↑ Summary Transport/Mailx.pm »
1 # This code is part of Perl distribution Mail-Transport version 4.01.
2 # The POD got stripped from this file by OODoc version 3.05.
3 # For contributors see file ChangeLog.
4  
5 # This software is copyright (c) 2001-2025 by Mark Overmeer.
6  
7 # This is free software; you can redistribute it and/or modify it under
8 # the same terms as the Perl 5 programming language system itself.
9 # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
10  
11  
12 package Mail::Transport;{
13 1 our $VERSION = '4.01';
14 }
15  
16 1 ▶use parent 'Mail::Reporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Log::Report 'mail-transport', import => [ qw/__x error panic/ ];
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 #--------------------
26  
27 1 my %mailers = (
28 exim => '::Exim',
29 imap => '::IMAP4',
30 imap4 => '::IMAP4',
31 mail => '::Mailx',
32 mailx => '::Mailx',
33 pop => '::POP3',
34 pop3 => '::POP3',
35 postfix => '::Sendmail',
36 qmail => '::Qmail',
37 sendmail => '::Sendmail',
38 smtp => '::SMTP'
39 );
40  
41  
42 sub new(@)
43 0 ▶{ my $class = shift;
Subroutine new: not called CC=7 SCAR=40.3
Pod documented
44  
45 0 ▶ $class eq __PACKAGE__ || $class eq "Mail::Transport::Send"
Branch: 1 branch
BranchTrueFalseTotal
$class eq __PACKAGE__ or $class eq "Mail::Transport::Send" or return $class->SUPER::new(@_) 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
46 or return $class->SUPER::new(@_);
47  
48 # auto restart by creating the right transporter.
49  
50 0 my %args = @_;
51 0 ▶ my $via = lc($args{via} // '') or panic "no transport protocol provided";
Branch: 1 branch
BranchTrueFalseTotal
my $via = lc($args{"via"} // "") or &panic("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
52  
53 0 ▶ $via = 'Mail::Transport'.$mailers{$via} if exists $mailers{$via};
Branch: 1 branch
BranchTrueFalseTotal
if exists $mailers{$via} 0 0 0
54 0 eval "require $via";
55 0 ▶ $@ ? undef : $via->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 0 0 0
56 }
57  
58 sub init($)
59 0 ▶{ my ($self, $args) = @_;
Subroutine init: not called CC=9 SCAR=45.0
Pod undocumented
60 0 $self->SUPER::init($args);
61  
62 0 ▶ $self->{MT_hostname} = $args->{hostname} // 'localhost';
Condition0%0/2
$args->{"hostname"} // "localhost"
l!l
00
MC/DC0%0/1
$args->{"hostname"} // "localhost"
$args->{"hostname"}
Truth table0%0/2
A
A= $args->{"hostname"}
Aresult
11
00
63 0 $self->{MT_port} = $args->{port};
64 0 $self->{MT_username} = $args->{username};
65 0 $self->{MT_password} = $args->{password};
66 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
67 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
68 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
69 0 $self->{MT_proxy} = $args->{proxy};
70  
71 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
72 0 { $self->{MT_exec} = $exec;
73  
74 0 ▶ File::Spec->file_name_is_absolute($exec)
Branch: 1 branch
BranchTrueFalseTotal
"File::Spec"->file_name_is_absolute($exec) or &error(&__x("avoid program abuse: specify an absolute path for {program}.", "program", $exec)) 0 0 0
75 or error __x"avoid program abuse: specify an absolute path for {program}.", program => $exec;
76  
77 0 ▶ -x $exec
Branch: 1 branch
BranchTrueFalseTotal
-x $exec or &error(&__x("executable {program} does not exist.", "program", $exec)) 0 0 0
78 or error __x"executable {program} does not exist.", program => $exec;
79 }
80  
81 0 $self;
82 }
83  
84 #--------------------
85  
86 0 ▶sub remoteHost() { @{$_[0]}{ qw/MT_hostname MT_port MT_username MT_password/ } }
Subroutine remoteHost: not called CC=1 SCAR=6.9
Pod documented
87  
88  
89 0 ▶sub retry() { @{$_[0]}{ qw/MT_interval MT_retry MT_timeout/ } }
Subroutine retry: not called CC=1 SCAR=6.9
Pod documented
90  
91  
92 1 my @safe_directories = qw(/usr/local/bin /usr/bin /bin /sbin /usr/sbin /usr/lib);
93  
94 sub findBinary($@)
95 0 ▶{ my ($self, $name) = (shift, shift);
Subroutine findBinary: not called CC=4 SCAR=30.0
Pod documented
96  
97 return $self->{MT_exec}
98 0 ▶ if exists $self->{MT_exec};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"MT_exec"} 0 0 0
99  
100 0 foreach (@_, @safe_directories)
101 0 { my $fullname = File::Spec->catfile($_, $name);
102 0 ▶ return $fullname if -x $fullname;
Branch: 1 branch
BranchTrueFalseTotal
if -x $fullname 0 0 0
103 }
104  
105 0 undef;
106 }
107  
108 #--------------------
109  
110 1 1;
« Transport/Send.pm ↑ Summary Transport/Mailx.pm »