Transport/Send.pm

filter: Statementstmt 37.1% 23 / 62 Branchbran 0.0% 0 / 36 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 58.3% 7 / 12 Podpod 100% 5 / 5 totaltotal 29.1% 35 / 120 SCAR 53.2
CC
20
Cov
23%
send
110.0
destinations
72.0
putContent
12.0
CRAP 204.2
« Transport/SMTP.pm ↑ Summary Transport.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::Send;
10 1 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 $VERSION = '3.005';
12  
13 1 ▶use base 'Mail::Transport';
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 1 ▶use Errno 'EAGAIN';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22  
23 sub new(@)
24 0 ▶{ my $class = shift;
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
25 0 ▶ return $class->SUPER::new(@_)
Branch: 1 branch
BranchTrueFalseTotal
if $class ne __PACKAGE__ 0 0 0
26 if $class ne __PACKAGE__;
27  
28 0 require Mail::Transport::Sendmail;
29 0 Mail::Transport::Sendmail->new(@_);
30 }
31  
32 #------------------------------------------
33  
34  
35 sub send($@)
36 0 ▶{ my ($self, $message, %args) = @_;
Subroutine send: not called CC=10 SCAR=47.0
Pod documented
37  
38 0 ▶ unless($message->isa('Mail::Message')) # avoid rebless.
Branch: 1 branch
BranchTrueFalseTotal
unless ($message->isa("Mail::Message")) 0 0 0
39 0 { $message = Mail::Message->coerce($message);
40 0 ▶ confess "Unable to coerce object into Mail::Message."
Branch: 1 branch
BranchTrueFalseTotal
unless defined $message 0 0 0
41 unless defined $message;
42 }
43  
44 0 ▶ return 1 if $self->trySend($message, %args);
Branch: 1 branch
BranchTrueFalseTotal
if $self->trySend($message, %args) 0 0 0
45 0 ▶ return 0 unless $?==EAGAIN;
Branch: 1 branch
BranchTrueFalseTotal
unless $? == 11 0 0 0
46  
47 0 my ($interval, $retry) = $self->retry;
48 0 ▶ $interval = $args{interval} if exists $args{interval};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"interval"} 0 0 0
49 0 ▶ $retry = $args{retry} if exists $args{retry};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"retry"} 0 0 0
50  
51 0 ▶ while($retry!=0)
Branch: 1 branch
BranchTrueFalseTotal
if ($retry != 0) 0 0 0
52 0 { sleep $interval;
53 0 ▶ return 1 if $self->trySend($message, %args);
Branch: 1 branch
BranchTrueFalseTotal
if $self->trySend($message, %args) 0 0 0
54 0 ▶ return 0 unless $?==EAGAIN;
Branch: 1 branch
BranchTrueFalseTotal
unless $? == 11 0 0 0
55 0 $retry--;
56 }
57  
58 0 0;
59 }
60  
61 #------------------------------------------
62  
63  
64 sub trySend($@)
65 0 ▶{ my $self = shift;
Subroutine trySend: not called CC=1 SCAR=6.9
Pod documented
66 0 $self->log(ERROR => "Transporters of type ".ref($self). " cannot send.");
67 }
68  
69 #------------------------------------------
70  
71  
72 sub putContent($$@)
73 0 ▶{ my ($self, $message, $fh, %args) = @_;
Subroutine putContent: not called CC=3 SCAR=24.8
Pod documented
74  
75 0 ▶ if($args{body_only}) { $message->body->print($fh) }
Branch: 2 branches
BranchTrueFalseTotal
if ($args{'body_only'}) { } 0 0 0
elsif ($args{'undisclosed'}) { } 0 0 0
76 0 elsif($args{undisclosed}) { $message->Mail::Message::print($fh) }
77 else
78 0 { $message->head->printUndisclosed($fh);
79 0 $message->body->print($fh);
80 }
81  
82 0 $self;
83 }
84  
85 #------------------------------------------
86  
87  
88 sub destinations($;$)
89 0 ▶{ my ($self, $message, $overrule) = @_;
Subroutine destinations: not called CC=8 SCAR=42.8
Pod documented
90 0 my @to;
91  
92 0 ▶ if(defined $overrule) # Destinations overruled by user.
Branch: 2 branches
BranchTrueFalseTotal
if (defined $overrule) { } 0 0 0
elsif (my(@rgs) = $message->head->resentGroups) { } 0 0 0
93 0 ▶ { my @addr = ref $overrule eq 'ARRAY' ? @$overrule : ($overrule);
Branch: 1 branch
BranchTrueFalseTotal
ref $overrule eq 'ARRAY' ? : 0 0 0
94 0 ▶ @to = map { ref $_ && $_->isa('Mail::Address') ? ($_)
Branch: 1 branch
BranchTrueFalseTotal
ref $_ && $_->isa('Mail::Address') ? : 0 0 0
Condition0%0/3
ref $_ and $_->isa("Mail::Address")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_ and $_->isa("Mail::Address")
ref $_ $_->isa("Mail::Address")
Truth table0%0/3
A and B
A= ref $_B= $_->isa("Mail::Address")
ABresult
0X0
100
111
95 : Mail::Address->parse($_) } @addr;
96 }
97 elsif(my @rgs = $message->head->resentGroups)
98 0 { @to = $rgs[0]->destinations;
99 0 ▶ $self->log(WARNING => "Resent group does not specify a destination"), return ()
Branch: 1 branch
BranchTrueFalseTotal
unless @to 0 0 0
100 unless @to;
101 }
102 else
103 0 { @to = $message->destinations;
104 0 ▶ $self->log(WARNING => "Message has no destination"), return ()
Branch: 1 branch
BranchTrueFalseTotal
unless @to 0 0 0
105 unless @to;
106 }
107  
108 0 @to;
109 }
110  
111 #------------------------------------------
112  
113  
114 1 1;
« Transport/SMTP.pm ↑ Summary Transport.pm »