Dispatch/Email/MailSend.pm

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 CC 1 SCAR 0.9
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Dispatch/Email/MIMELite.pm ↑ Summary Dispatch/Email/MailSendmail.pm »
1 package Log::Dispatch::Email::MailSend;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 our $VERSION = '2.71';
7  
8 0 ▶use Mail::Send;
Subroutine BEGIN: called CC=1 SCAR=2.6
9 use Try::Tiny;
10  
11 use base qw( Log::Dispatch::Email );
12  
13 sub send_email {
14 my $self = shift;
15 my %p = @_;
16  
17 my $msg = Mail::Send->new;
18  
19 $msg->to( join ',', @{ $self->{to} } );
20 $msg->subject( $self->{subject} );
21  
22 # Does this ever work for this module?
23 $msg->set( 'From', $self->{from} ) if $self->{from};
24  
25 local $? = 0;
26 return
27 if try {
28 my $fh = $msg->open
29 or die 'Cannot open handle to mail program';
30  
31 $fh->print( $p{message} )
32 or die 'Cannot print message to mail program handle';
33  
34 $fh->close
35 or die 'Cannot close handle to mail program';
36  
37 1;
38 };
39  
40 warn $@ if $@;
41 }
42  
43 1;
44  
45 # ABSTRACT: Subclass of Log::Dispatch::Email that uses the Mail::Send module
46  
47 __END__
« Dispatch/Email/MIMELite.pm ↑ Summary Dispatch/Email/MailSendmail.pm »