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   476 use strict;
  1         3  
  1         29  
4 1     1   5 use warnings;
  1         2  
  1         39  
5              
6             our $VERSION = '2.71';
7              
8 1     1   228 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.71
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 send_email
69             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             =head1 SOURCE
76              
77             The source code repository for Log-Dispatch can be found at L<https://github.com/houseabsolute/Log-Dispatch>.
78              
79             =head1 AUTHOR
80              
81             Dave Rolsky <autarch@urth.org>
82              
83             =head1 COPYRIGHT AND LICENSE
84              
85             This software is Copyright (c) 2023 by Dave Rolsky.
86              
87             This is free software, licensed under:
88              
89             The Artistic License 2.0 (GPL Compatible)
90              
91             The full text of the license can be found in the
92             F<LICENSE> file included with this distribution.
93              
94             =cut