1Log::Handler::Output::EUmsaeirl(C3o)ntributed Perl DocumLeongt:a:tHiaonndler::Output::Email(3)
2
3
4

NAME

6       Log::Handler::Output::Email - Log messages as email (via Net::SMTP).
7

SYNOPSIS

9           use Log::Handler::Output::Email;
10
11           my $email = Log::Handler::Output::Email->new(
12               host     => "mx.bar.example",
13               hello    => "EHLO my.domain.example",
14               timeout  => 120,
15               debug    => 0,
16               from     => 'bar@foo.example',
17               to       => 'foo@bar.example',
18               subject  => "your subject",
19               buffer   => 0
20           );
21
22           $email->log(message => $message);
23

DESCRIPTION

25       With this output module it's possible to log messages via email and it
26       used Net::SMTP to do it. The date for the email is generated with
27       "Email::Date::format_date".
28
29       Net::SMTP is from Graham Barr and it does it's job very well.
30

METHODS

32   new()
33       Call "new()" to create a new Log::Handler::Output::Email object.
34
35       The following opts are possible:
36
37       host
38           With this option you has to define the SMTP host to connect to.
39
40               host => "mx.host.com"
41
42               # or
43
44               host => [ "mx.host.example", "mx.host-backup.example" ]
45
46       hello
47           Identify yourself with a HELO. The default is set to "EHLO BELO".
48
49       timeout
50           With this option you can set the maximum time in seconds to wait
51           for a response from the SMTP server. The default is set to 120
52           seconds.
53
54       from
55           The sender address (MAIL FROM).
56
57       to  The receipient address (RCPT TO).
58
59           Additional options are cc and bcc.
60
61       subject
62           The subject of the mail.
63
64           The default subject is "Log message from $progname".
65
66       buffer
67           This opts exists only for security. The thing is that it would be
68           very bad if something wents wrong in your program and hundreds of
69           mails would be send.  For this reason you can set a buffer to take
70           care.
71
72           With the buffer you can set the maximum size of the buffer in
73           lines. If you set
74
75               buffer => 10
76
77           then 10 messages would be buffered. Set "buffer" to 0 if you want
78           to disable the buffer.
79
80           The default buffer size is set to 20.
81
82       debug
83           With this option it's possible to enable debugging. The information
84           can be intercepted with $SIG{__WARN__}.
85
86   log()
87       Call "log()" if you want to log a message as email.
88
89       If you set a buffer size then the message will be pushed into the
90       buffer first.
91
92       Example:
93
94           $email->log(message => "this message will be mailed");
95
96       If you pass the level then its placed into the subject:
97
98           $email->log(message => "foo", level => "INFO");
99           $email->log(message => "bar", level => "ERROR");
100           $email->log(message => "baz", level => "DEBUG");
101
102       The lowest level is used:
103
104           Subject: ERROR: ...
105
106       You can pass the level with "Log::Handler" by setting
107
108           message_pattern => '%L'
109
110   flush()
111       Call "flush()" if you want to flush the buffered lines.
112
113   sendmail()
114       Call "sendmail()" if you want to send an email.
115
116       The difference to "log()" is that the message won't be buffered.
117
118   validate()
119       Validate a configuration.
120
121   reload()
122       Reload with a new configuration.
123
124   errstr()
125       This function returns the last error message.
126

DESTROY

128       "DESTROY" is defined and called "flush()".
129

PREREQUISITES

131           Carp
132           Email::Date
133           Net::SMTP
134           Params::Validate
135

EXPORTS

137       No exports.
138

REPORT BUGS

140       Please report all bugs to <jschulz.cpan(at)bloonix.de>.
141
142       If you send me a mail then add Log::Handler into the subject.
143

AUTHOR

145       Jonny Schulz <jschulz.cpan(at)bloonix.de>.
146
148       Copyright (C) 2007-2009 by Jonny Schulz. All rights reserved.
149
150       This program is free software; you can redistribute it and/or modify it
151       under the same terms as Perl itself.
152
153
154
155perl v5.30.1                      2020-01-30    Log::Handler::Output::Email(3)
Impressum