1package Log::Dispatch::Email::MailSendmail; 2{ 3 $Log::Dispatch::Email::MailSendmail::VERSION = '2.34'; 4} 5 6use strict; 7use warnings; 8 9use Log::Dispatch::Email; 10 11use base qw( Log::Dispatch::Email ); 12 13use Mail::Sendmail (); 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 Message => $p{message}, 23 24 # Mail::Sendmail insists on having this parameter. 25 From => $self->{from} || 'LogDispatch@foo.bar', 26 ); 27 28 local $?; 29 unless ( Mail::Sendmail::sendmail(%mail) ) { 30 warn "Error sending mail: $Mail::Sendmail::error"; 31 } 32} 33 341; 35 36# ABSTRACT: Subclass of Log::Dispatch::Email that uses the Mail::Sendmail module 37 38__END__ 39 40=pod 41 42=head1 NAME 43 44Log::Dispatch::Email::MailSendmail - Subclass of Log::Dispatch::Email that uses the Mail::Sendmail 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::MailSendmail', 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<Mail::Sendmail> 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