Transport/Send.pm

filter: Statementstmt 36.8% 21 / 57 Branchbran 0.0% 0 / 34 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 54.5% 6 / 11 Podpod 100% 5 / 5 totaltotal 28.5% 32 / 112 CC 19 SCAR 39.1
CC
19
Cov
22%
send
90.0
destinations
72.0
putContent
12.0
CRAP 49.7
« Transport/SMTP.pm ↑ Summary Transport.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::Send;{
13 1 our $VERSION = '4.01';
14 }
15  
16 1 ▶use parent 'Mail::Transport';
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 warning/ ];
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Errno 'EAGAIN';
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 #--------------------
27  
28 sub new(@)
29 0 ▶{ my $class = shift;
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
30 0 ▶ $class eq __PACKAGE__ or return $class->SUPER::new(@_);
Branch: 1 branch
BranchTrueFalseTotal
$class eq __PACKAGE__ or return $class->SUPER::new(@_) 0 0 0
31  
32 0 require Mail::Transport::Sendmail;
33 0 Mail::Transport::Sendmail->new(@_);
34 }
35  
36 #--------------------
37  
38 sub send($@)
39 0 ▶{ my ($self, $message, %args) = @_;
Subroutine send: not called CC=9 SCAR=45.0
Pod documented
40  
41 0 ▶ $message = Mail::Message->coerce($message)
Branch: 1 branch
BranchTrueFalseTotal
unless $message->isa("Mail::Message") 0 0 0
42 unless $message->isa('Mail::Message');
43  
44 0 ▶ $self->trySend($message, %args)
Branch: 1 branch
BranchTrueFalseTotal
$self->trySend($message, %args) and return 1 0 0 0
45 and return 1;
46  
47 0 ▶ $?==EAGAIN
Branch: 1 branch
BranchTrueFalseTotal
$? == 11 or return 0 0 0 0
48 or return 0;
49  
50 0 my ($interval, $retry) = $self->retry;
51 0 ▶ $interval = $args{interval} if exists $args{interval};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"interval"} 0 0 0
52 0 ▶ $retry = $args{retry} if exists $args{retry};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"retry"} 0 0 0
53  
54 0 ▶ while($retry!=0)
Branch: 1 branch
BranchTrueFalseTotal
if ($retry != 0) 0 0 0
55 0 { sleep $interval;
56 0 ▶ return 1 if $self->trySend($message, %args);
Branch: 1 branch
BranchTrueFalseTotal
if $self->trySend($message, %args) 0 0 0
57 0 ▶ $?==EAGAIN or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$? == 11 or return 0 0 0 0
58 0 $retry--;
59 }
60  
61 0 0;
62 }
63  
64  
65 sub trySend($@)
66 0 ▶{ my $self = shift;
Subroutine trySend: not called CC=1 SCAR=6.9
Pod documented
67 0 error __x"transporters of type {class} cannot send.", class => ref $self;
68 }
69  
70  
71 sub putContent($$@)
72 0 ▶{ my ($self, $message, $fh, %args) = @_;
Subroutine putContent: not called CC=3 SCAR=24.8
Pod documented
73  
74 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
75 0 elsif($args{undisclosed}) { $message->Mail::Message::print($fh) }
76 else
77 0 { $message->head->printUndisclosed($fh);
78 0 $message->body->print($fh);
79 }
80  
81 0 $self;
82 }
83  
84  
85  
86 sub destinations($;$)
87 0 ▶{ my ($self, $message, $overrule) = @_;
Subroutine destinations: not called CC=8 SCAR=42.8
Pod documented
88 0 my @to;
89  
90 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
91 0 ▶ { @to = map { ref $_ && $_->isa('Mail::Address') ? ($_) : Mail::Address->parse($_) }
Branch: 2 branches
BranchTrueFalseTotal
ref $_ && $_->isa('Mail::Address') ? : 0 0 0
ref $overrule eq 'ARRAY' ? : 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
92 ref $overrule eq 'ARRAY' ? @$overrule : ($overrule);
93 }
94 elsif(my @rgs = $message->head->resentGroups)
95 { # Create with bounce
96 0 @to = $rgs[0]->destinations;
97 0 ▶ @to or warning(__x"resent group does not specify a destination."), return ();
Branch: 1 branch
BranchTrueFalseTotal
@to or &warning(&__x("resent group does not specify a destination.")), (return ()) 0 0 0
98 }
99 else
100 0 { @to = $message->destinations;
101 0 ▶ @to or warning(__x"message has no destination."), return ();
Branch: 1 branch
BranchTrueFalseTotal
@to or &warning(&__x("message has no destination.")), (return ()) 0 0 0
102 }
103  
104 0 @to;
105 }
106  
107 #--------------------
108  
109 1 1;
« Transport/SMTP.pm ↑ Summary Transport.pm »