File Coverage

blib/lib/Log/Dispatch/Email/MIMELite.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package Log::Dispatch::Email::MIMELite;
2              
3 1     1   354 use strict;
  1         2  
  1         23  
4 1     1   4 use warnings;
  1         1  
  1         30  
5              
6             our $VERSION = '2.69';
7              
8 1     1   138 use MIME::Lite;
  0            
  0            
9              
10             use base qw( Log::Dispatch::Email );
11              
12             sub send_email {
13             my $self = shift;
14             my %p = @_;
15              
16             my %mail = (
17             To => ( join ',', @{ $self->{to} } ),
18             Subject => $self->{subject},
19             Type => 'TEXT',
20             Data => $p{message},
21             );
22              
23             $mail{From} = $self->{from} if defined $self->{from};
24              
25             local $? = 0;
26             unless ( MIME::Lite->new(%mail)->send ) {
27             warn 'Error sending mail with MIME::Lite';
28             }
29             }
30              
31             1;
32              
33             # ABSTRACT: Subclass of Log::Dispatch::Email that uses the MIME::Lite module
34              
35             __END__
36              
37             =pod
38              
39             =encoding UTF-8
40              
41             =head1 NAME
42              
43             Log::Dispatch::Email::MIMELite - Subclass of Log::Dispatch::Email that uses the MIME::Lite module
44              
45             =head1 VERSION
46              
47             version 2.69
48              
49             =head1 SYNOPSIS
50              
51             use Log::Dispatch;
52              
53             my $log = Log::Dispatch->new(
54             outputs => [
55             [
56             'Email::MIMELite',
57             min_level => 'emerg',
58             to => [qw( foo@example.com bar@example.org )],
59             subject => 'Big error!'
60             ]
61             ],
62             );
63              
64             $log->emerg("Something bad is happening");
65              
66             =head1 DESCRIPTION
67              
68             This is a subclass of L<Log::Dispatch::Email> that implements the
69             send_email method using the L<MIME::Lite> module.
70              
71             =head1 SUPPORT
72              
73             Bugs may be submitted at L<https://github.com/houseabsolute/Log-Dispatch/issues>.
74              
75             I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>.
76              
77             =head1 SOURCE
78              
79             The source code repository for Log-Dispatch can be found at L<https://github.com/houseabsolute/Log-Dispatch>.
80              
81             =head1 AUTHOR
82              
83             Dave Rolsky <autarch@urth.org>
84              
85             =head1 COPYRIGHT AND LICENSE
86              
87             This software is Copyright (c) 2019 by Dave Rolsky.
88              
89             This is free software, licensed under:
90              
91             The Artistic License 2.0 (GPL Compatible)
92              
93             The full text of the license can be found in the
94             F<LICENSE> file included with this distribution.
95              
96             =cut