line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Dispatch::Email::MailSendmail; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
467
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '2.70'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
167
|
use Mail::Sendmail (); |
|
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
|
|
|
|
|
|
|
Message => $p{message}, |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Mail::Sendmail insists on having this parameter. |
22
|
|
|
|
|
|
|
From => $self->{from} || 'LogDispatch@foo.bar', |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
local $? = 0; |
26
|
|
|
|
|
|
|
unless ( Mail::Sendmail::sendmail(%mail) ) { |
27
|
|
|
|
|
|
|
warn "Error sending mail: $Mail::Sendmail::error"; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# ABSTRACT: Subclass of Log::Dispatch::Email that uses the Mail::Sendmail module |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=pod |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=encoding UTF-8 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 NAME |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Log::Dispatch::Email::MailSendmail - Subclass of Log::Dispatch::Email that uses the Mail::Sendmail module |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 VERSION |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
version 2.70 |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 SYNOPSIS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
use Log::Dispatch; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $log = Log::Dispatch->new( |
54
|
|
|
|
|
|
|
outputs => [ |
55
|
|
|
|
|
|
|
[ |
56
|
|
|
|
|
|
|
'Email::MailSendmail', |
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<Mail::Sendmail> 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) 2020 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 |