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

filter: Statementstmt 33.3% 11 / 33 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 20.8% 15 / 72 CC 16 SCAR 54.3
CC
16
Cov
17%
mail
272.0
BEGIN
1.0
BEGIN
1.0
CRAP 229.2
↑ Summary blib/lib/Test/Smoke/Mailer/SendEmail.pm »
1 package Test::Smoke::Mailer::MIME_Lite;
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::MIME_Lite
10  
11 This handles sending the message using the B<MIME::Lite> module.
12  
13 =head1 DESCRIPTION
14  
15 =head2 Test::Smoke::Mailer::MIME_Lite->new( %args )
16  
17 Keys for C<%args>:
18  
19 * ddir
20 * mserver
21 * msport
22 * msuser
23 * mspass
24 * to
25 * from
26 * cc
27 * v
28  
29 =cut
30  
31 =head2 $mailer->mail( )
32  
33 C<mail()> sets up the message to be send by B<MIME::Lite>.
34  
35 =cut
36  
37 0 ▶sub mail {
Subroutine mail: not called CC=16 SCAR=56.1
Pod documented
38 0 my $self = shift;
39  
40 0 eval { require MIME::Lite; };
41  
42 0 ▶ $self->{error} = $@ and return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"error"} = $@ and return undef 0 0 0
43  
44 0 my $subject = $self->fetch_report();
45 0 my $cc = $self->_get_cc( $subject );
46  
47 my %message = (
48 To => $self->{to},
49 Subject => $subject,
50 Type => "TEXT",
51 Data => $self->{body},
52 0 );
53 0 ▶ $message{Cc} = $cc if $cc;
Branch: 1 branch
BranchTrueFalseTotal
if $cc 0 0 0
54 0 ▶ $message{Bcc} = $self->{bcc} if $self->{bcc};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"bcc"} 0 0 0
55 0 ▶ $message{From} = $self->{from} if $self->{from};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"from"} 0 0 0
56  
57 0 ▶ if ($self->{mserver}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"mserver"}) 0 0 0
58 0 my %authinfo = ();
59 0 ▶ $authinfo{AuthUser} = $self->{msuser} if $self->{msuser};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"msuser"} 0 0 0
60 0 ▶ $authinfo{AuthPass} = $self->{mspass} if defined $self->{mspass};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"mspass"} 0 0 0
61 MIME::Lite->send(
62 smtp => $self->{mserver},
63 Port => ($self->{msport} || 25),
64 FromSender => $self->{from},
65 0 ▶ Debug => ($self->{v} > 1),
Condition0%0/2
$self->{'msport'} || 25
l!l
00
MC/DC0%0/1
$self->{'msport'} || 25
$self->{'msport'}
Truth table0%0/2
A
A= $self->{'msport'}
Aresult
11
00
66 %authinfo,
67 );
68 }
69  
70 0 my $ml_msg = MIME::Lite->new( %message );
71 $ml_msg->attr( 'content-type.charset' => 'UTF8' )
72 0 ▶ if exists $ENV{LANG} && $ENV{LANG} =~ /utf-?8$/i;
Branch: 1 branch
BranchTrueFalseTotal
if exists $ENV{"LANG"} and $ENV{"LANG"} =~ /utf-?8$/i 0 0 0
Condition0%0/3
exists $ENV{"LANG"} and $ENV{"LANG"} =~ /utf-?8$/i
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ENV{"LANG"} and $ENV{"LANG"} =~ /utf-?8$/i
exists $ENV{"LANG"} $ENV{"LANG"} =~ /utf-?8$/i
Truth table0%0/3
A and B
A= exists $ENV{"LANG"}B= $ENV{"LANG"} =~ /utf-?8$/i
ABresult
0X0
100
111
73  
74 0 ▶ $self->{v} > 1 and print "[MIME::Lite]\n";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"v"} > 1 and print "[MIME::Lite]\n" 0 0 0
75 0 ▶ $self->{v} and print "Sending report to $self->{to} ";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"v"} and print qq[Sending report to $self->{"to"} ] 0 0 0
76  
77 0 ▶ $ml_msg->send or $self->{error} = "Problem sending mail";
Branch: 1 branch
BranchTrueFalseTotal
$ml_msg->send or $self->{"error"} = "Problem sending mail" 0 0 0
78  
79 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
80  
81 0 return ! $self->{error};
82 }
83  
84 3 1;
85  
86 =head1 COPYRIGHT
87  
88 (c) 2002-2013, All rights reserved.
89  
90 * Abe Timmerman <abeltje@cpan.org>
91  
92 This library is free software; you can redistribute it and/or modify
93 it under the same terms as Perl itself.
94  
95 See:
96  
97 * <http://www.perl.com/perl/misc/Artistic.html>,
98 * <http://www.gnu.org/copyleft/gpl.html>
99  
100 This program is distributed in the hope that it will be useful,
101 but WITHOUT ANY WARRANTY; without even the implied warranty of
102 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
103  
104 =cut
↑ Summary blib/lib/Test/Smoke/Mailer/SendEmail.pm »