Transport/Mailx.pm

filter: Statementstmt 28.3% 17 / 60 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 62.5% 5 / 8 Podpod 50.0% 1 / 2 totaltotal 21.9% 23 / 105 SCAR 49.1
CC
15
Cov
19%
init
72.0
_try_send_bsdish
30.0
trySend
20.0
CRAP 136.0
« Transport.pm ↑ Summary Transport/Exim.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::Mailx;
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::Send';
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  
20  
21 sub init($)
22 0 ▶{ my ($self, $args) = @_;
Subroutine init: not called CC=8 SCAR=42.8
Pod undocumented
23  
24 0 $args->{via} = 'mailx';
25  
26 0 ▶ $self->SUPER::init($args) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init($args) or return 0 0 0
27  
28 $self->{MTM_program}
29 = $args->{proxy}
30 0 ▶ || $self->findBinary('mailx')
Condition0%0/11
$args->{'proxy'} || $self->findBinary('mailx') || $self->findBinary('Mail') || $self->findBinary('mail') || (return)
l!l
00
$args->{"proxy"} or $self->findBinary("mailx") or $self->findBinary("Mail") or $self->findBinary("mail")
l!l&&r!l&&!r
000
$args->{"proxy"} or $self->findBinary("mailx") or $self->findBinary("Mail")
l!l&&r!l&&!r
000
$args->{"proxy"} or $self->findBinary("mailx")
l!l&&r!l&&!r
000
MC/DC0%0/4
$args->{'proxy'} || $self->findBinary('mailx') || $self->findBinary('Mail') || $self->findBinary('mail') || (return)
$args->{"proxy"} $self->findBinary("mailx") $self->findBinary("Mail") $self->findBinary("mail")
Truth table0%0/5
A or B or C or D
A= $args->{"proxy"}B= $self->findBinary("mailx")C= $self->findBinary("Mail")D= $self->findBinary("mail")
ABCDresult
1XXX1
01XX1
001X1
00011
00000
31 || $self->findBinary('Mail')
32 || $self->findBinary('mail')
33 || return;
34  
35 $self->{MTM_style}
36 = defined $args->{style} ? $args->{style}
37 0 ▶ : $^O =~ m/linux|freebsd|bsdos|netbsd|openbsd/ ? 'BSD'
Branch: 2 branches
BranchTrueFalseTotal
defined $args->{'style'} ? : 0 0 0
$^O =~ /linux|freebsd|bsdos|netbsd|openbsd/ ? : 0 0 0
38 : 'RFC822';
39  
40 0 $self;
41 }
42  
43 #------------------------------------------
44  
45  
46 sub _try_send_bsdish($$)
47 0 ▶{ my ($self, $message, $args) = @_;
Subroutine _try_send_bsdish: not called CC=5 SCAR=34.0
48  
49 0 my @options = ('-s' => $message->subject);
50  
51 0 { local $" = ',';
52 0 my @cc = map {$_->format} $message->cc;
53 0 ▶ push @options, ('-c' => "@cc") if @cc;
Branch: 1 branch
BranchTrueFalseTotal
if @cc 0 0 0
54  
55 0 my @bcc = map {$_->format} $message->bcc;
56 0 ▶ push @options, ('-b' => "@bcc") if @bcc;
Branch: 1 branch
BranchTrueFalseTotal
if @bcc 0 0 0
57 }
58  
59 0 my @to = map {$_->format} $message->to;
60 0 my $program = $self->{MTM_program};
61  
62 0 ▶ if((open MAILER, '|-')==0)
Branch: 1 branch
BranchTrueFalseTotal
if (open(MAILER, "|-") == 0) 0 0 0
63 0 { close STDOUT;
64 0 { exec $program, @options, @to }
65 0 $self->log(NOTICE => "Cannot start contact to $program: $!");
66 0 exit 1;
67 }
68
69 0 $self->putContent($message, \*MAILER, body_only => 1);
70  
71 0 my $msgid = $message->messageId;
72  
73 0 ▶ if(close MAILER) { $self->log(PROGRESS => "Message $msgid send.") }
Branch: 1 branch
BranchTrueFalseTotal
if (close MAILER) { } 0 0 0
74 else
75 0 { $self->log(ERROR => "Sending via mailx mailer $program failed: $! ($?)");
76 0 return 0;
77 }
78  
79 0 1;
80 }
81  
82 sub trySend($@)
83 0 ▶{ my ($self, $message, %args) = @_;
Subroutine trySend: not called CC=4 SCAR=30.0
Pod documented
84  
85 return $self->_try_send_bsdish($message, \%args)
86 0 ▶ if $self->{MTM_style} eq 'BSD';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"MTM_style"} eq "BSD" 0 0 0
87  
88 0 my $program = $self->{MTM_program};
89 0 ▶ unless(open MAILER, '|-', $program, '-t')
Branch: 1 branch
BranchTrueFalseTotal
unless (open MAILER, "|-", $program, "-t") 0 0 0
90 0 { $self->log(NOTICE => "Cannot start contact to $program: $!");
91 0 return 0;
92 }
93
94 0 $self->putContent($message, \*MAILER);
95  
96 0 ▶ unless(close MAILER)
Branch: 1 branch
BranchTrueFalseTotal
unless (close MAILER) 0 0 0
97 0 { $self->log(ERROR => "Sending via mailx mailer $program failed: $! ($?)");
98 0 return 0;
99 }
100  
101 0 1;
102 }
103  
104 #------------------------------------------
105  
106 1 1;
« Transport.pm ↑ Summary Transport/Exim.pm »