
Log::Fine::Handle::Email - Email log messages to one or more addresses

Provides messaging to one or more email addresses.
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP qw();
use Log::Fine;
use Log::Fine::Handle::Email;
use Log::Fine::Levels::Syslog;
# Get a new logger
my $log = Log::Fine->logger("foo");
# Create a formatter object for subject line
my $subjfmt = Log::Fine::Formatter::Template
->new( name => 'template1',
template => "%%LEVEL%% : The angels have my blue box" );
# Create a formatted msg template
my $msgtmpl = <<EOF;
The program, $0, has encountered the following error condition:
%%MSG%% at %%TIME%%
Contact Operations at 1-800-555-5555 immediately!
EOF
my $bodyfmt = Log::Fine::Formatter::Template
->new( name => 'template2',
template => $msgtmpl );
# Define an optional transport
# register an email handle
my $handle = Log::Fine::Handle::Email
->new( name => 'email0',
mask => LOGMASK_EMERG | LOGMASK_ALERT | LOGMASK_CRIT,
subject_formatter => $subjfmt,
body_formatter => $bodyfmt,
header_from => "alerts@example.com",
header_to => [ "critical_alerts@example.com" ],
envelope =>
{ to => [ "critical_alerts@example.com" ],
from => "alerts@example.com",
transport =>
Email::Sender::Transport::SMTP->new({ host => 'smtp.example.com' }),
}
);
# register the handle
$log->registerHandle($handle);
# log something
$log->log(CRIT, "Beware the weeping angels");

Log::Fine::Handle::Email provides formatted message delivery to one or more email addresses. The intended use is for programs that need to alert a user in the event of a critical condition. Conceivably, the destination address could be a pager or cell phone.
Log::Fine::Handle::Email uses the Email::Sender framework for delivery of emails. Users who wish to use Log::Fine::Handle::Email are strongly encouraged to read the following documentation:
Be especially mindful of the following environment variables as they will take precedence when defining a transport:
EMAIL_SENDER_TRANSPORTEMAIL_SENDER_TRANSPORT_hostEMAIL_SENDER_TRANSPORT_portSee Email::Sender::Manual::Quickstart for further details.
The following parameters can be passed to Log::Fine::Handle::Email->new();
[optional] Name of this object (see Log::Fine). Will be auto-set if not specified.
Mask to set the handle to (see Log::Fine::Handle)
A Log::Fine::Formatter object. Will be used to format the Email Subject Line.
A Log::Fine::Formatter object. Will be used to format the body of the message.
String containing text to be placed in "From" header of generated email.
String containing text to be placed in "To" header of generated email.
[optional] hash ref containing envelope information for email:
array ref containing one or more destination addresses
String containing email sender
An Email::Sender::Transport object. See Email::Sender::Manual for further details.

See "msgWrite" in Log::Fine::Handle

Please report any bugs or feature requests to bug-log-fine-handle-email at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Log-Fine. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

You can find documentation for this module with the perldoc command.
perldoc Log::Fine
You can also look for information at:

$Id: 428956bd20e56ad93dda9cca338a4f8d462cdf03 $

Christopher M. Fuhrman, <cfuhrman at panix.com>

perl, Log::Fine, Log::Fine::Handle

Copyright (c) 2011 Christopher M. Fuhrman, All rights reserved.
This program is free software licensed under the...
The BSD License
The full text of the license can be found in the LICENSE file included with this module.