blib/lib/Test/Smoke/Mailer/SendEmail.pm

filter: Statementstmt 31.4% 11 / 35 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 21.4% 15 / 70 CC 15 SCAR 53.0
CC
15
Cov
17%
mail
240.0
BEGIN
1.0
BEGIN
1.0
CRAP 200.2
« blib/lib/Test/Smoke/Mailer/MIME_Lite.pm ↑ Summary blib/lib/Test/Smoke.pm »
1 package Test::Smoke::Mailer::SendEmail;
2 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 our $VERSION = '0.016';
6  
7 3 ▶use base 'Test::Smoke::Mailer::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 =head1 Test::Smoke::Mailer::SendEmail
10  
11 This handles sending the message with the B<sendEmail> program.
12  
13 =head1 DESCRIPTION
14  
15 =head2 Test::Smoke::Mailer::SendEmail->new( %args )
16  
17 Keys for C<%args>:
18  
19 * ddir
20 * mserver
21 * msport
22 * msuser
23 * mspass
24 * sendemailbin
25 * to
26 * from
27 * cc
28 * v
29  
30 =cut
31  
32 =head2 $mailer->mail( )
33  
34 C<mail()> sets up the commandline and body and passes it to the
35 B<sendemail> program.
36  
37 =cut
38  
39 0 ▶sub mail {
Subroutine mail: not called CC=15 SCAR=54.8
Pod documented
40 0 my $self = shift;
41  
42 0 my $mailer = $self->{sendemailbin};
43  
44 0 my $subject = $self->fetch_report();
45 0 my $cc = $self->_get_cc( $subject );
46  
47 0 my $cmdline = qq|$mailer -u "$subject"|;
48 0 ▶ $self->{swcc} ||= '-cc', $cmdline .= qq| $self->{swcc} "$cc"| if $cc;
Branch: 1 branch
BranchTrueFalseTotal
if $cc 0 0 0
Condition0%0/2
$self->{"swcc"} ||= "-cc"
l!l
00
MC/DC0%0/1
$self->{"swcc"} ||= "-cc"
$self->{"swcc"}
Truth table0%0/2
A
A= $self->{"swcc"}
Aresult
11
00
49 $self->{swbcc} ||= '-bcc', $cmdline .= qq| $self->{swbcc} "$self->{bcc}"|
50 0 ▶ if $self->{bcc};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"bcc"} 0 0 0
Condition0%0/2
$self->{"swbcc"} ||= "-bcc"
l!l
00
MC/DC0%0/1
$self->{"swbcc"} ||= "-bcc"
$self->{"swbcc"}
Truth table0%0/2
A
A= $self->{"swbcc"}
Aresult
11
00
51 0 $cmdline .= qq| -t "$self->{to}"|;
52 0 ▶ $cmdline .= qq| -f "$self->{from}"| if $self->{from};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"from"} 0 0 0
53  
54 0 ▶ if ($self->{mserver}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"mserver"}) 0 0 0
55 0 my $mserver = $self->{mserver};
56 0 ▶ if ($self->{msport}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"msport"}) 0 0 0
57 0 $mserver .= ":$self->{msport}";
58 }
59 0 $cmdline .= qq| -s "$mserver"|;
60 }
61  
62 0 ▶ $cmdline .= qq| -xu "$self->{msuser}"| if $self->{msuser};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"msuser"} 0 0 0
63 0 ▶ $cmdline .= qq| -xp "$self->{mspass}"| if defined $self->{mspass};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"mspass"} 0 0 0
64 0 $cmdline .= qq| -o message-file="$self->{file}"|;
65  
66 0 ▶ $self->{v} > 1 and print "[$cmdline]\n";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"v"} > 1 and print "[$cmdline]\n" 0 0 0
67 0 ▶ $self->{v} and print "Sending report to $self->{to}\n";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"v"} and print qq[Sending report to $self->{"to"}\n] 0 0 0
68 0 system $cmdline;
69 0 ▶ if ($?) {
Branch: 1 branch
BranchTrueFalseTotal
if ($?) 0 0 0
70 0 $self->{error} = "Error executing '$mailer': " . $?>>8;
71 }
72 0 ▶ $self->{v} and print $self->{error} ? "not OK\n" : "OK\n";
Branch: 2 branches
BranchTrueFalseTotal
$self->{"v"} and print $self->{"error"} ? "not OK\n" : "OK\n" 0 0 0
$self->{'error'} ? : 0 0 0
73  
74 0 return ! $self->{error};
75 }
76  
77 3 1;
78  
79 =head1 COPYRIGHT
80  
81 (c) 2002-2013, All rights reserved.
82  
83 * Abe Timmerman <abeltje@cpan.org>
84  
85 This library is free software; you can redistribute it and/or modify
86 it under the same terms as Perl itself.
87  
88 See:
89  
90 * <http://www.perl.com/perl/misc/Artistic.html>,
91 * <http://www.gnu.org/copyleft/gpl.html>
92  
93 This program is distributed in the hope that it will be useful,
94 but WITHOUT ANY WARRANTY; without even the implied warranty of
95 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
96  
97 =cut
« blib/lib/Test/Smoke/Mailer/MIME_Lite.pm ↑ Summary blib/lib/Test/Smoke.pm »