1package Log::Dispatch::Email::MIMELite; 2{ 3 $Log::Dispatch::Email::MIMELite::VERSION = '2.34'; 4} 5 6use strict; 7use warnings; 8 9use Log::Dispatch::Email; 10 11use base qw( Log::Dispatch::Email ); 12 13use MIME::Lite; 14 15sub send_email { 16 my $self = shift; 17 my %p = @_; 18 19 my %mail = ( 20 To => ( join ',', @{ $self->{to} } ), 21 Subject => $self->{subject}, 22 Type => 'TEXT', 23 Data => $p{message}, 24 ); 25 26 $mail{From} = $self->{from} if defined $self->{from}; 27 28 local $?; 29 unless ( MIME::Lite->new(%mail)->send ) { 30 warn "Error sending mail with MIME::Lite"; 31 } 32} 33 341; 35 36# ABSTRACT: Subclass of Log::Dispatch::Email that uses the MIME::Lite module 37 38__END__ 39 40=pod 41 42=head1 NAME 43 44Log::Dispatch::Email::MIMELite - Subclass of Log::Dispatch::Email that uses the MIME::Lite module 45 46=head1 VERSION 47 48version 2.34 49 50=head1 SYNOPSIS 51 52 use Log::Dispatch; 53 54 my $log = Log::Dispatch->new( 55 outputs => [ 56 [ 57 'Email::MIMELite', 58 min_level => 'emerg', 59 to => [qw( foo@example.com bar@example.org )], 60 subject => 'Big error!' 61 ] 62 ], 63 ); 64 65 $log->emerg("Something bad is happening"); 66 67=head1 DESCRIPTION 68 69This is a subclass of L<Log::Dispatch::Email> that implements the 70send_email method using the L<MIME::Lite> module. 71 72=head1 AUTHOR 73 74Dave Rolsky <autarch@urth.org> 75 76=head1 COPYRIGHT AND LICENSE 77 78This software is Copyright (c) 2011 by Dave Rolsky. 79 80This is free software, licensed under: 81 82 The Artistic License 2.0 (GPL Compatible) 83 84=cut 85