NAME

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

SYNOPSIS

Provides messaging to one or more email addresses.

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 );

# 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       => 'Critical Alerts <alerts@example.com>',
           header_to         => 'critical_alerts@example.com',
           email_handle      => "EmailSender",       # <-- default value
           envelope          => {
               from => 'alerts@example.com',
               to   => ['critical_alerts@example.com',
                        'techoncall@example.com',
                        'techops@example.com'],
           }
         );

# register the handle
$log->registerHandle($handle);

# log something
$log->log(CRIT, "Beware the weeping angels");

DESCRIPTION

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.

EMAIL INTERFACES

Up until Log::Fine v0.59, the Email::Sender framework was used to do the heavy lifting of delivery of emails. While powerful and configurable, the Email::Sender framework required a hefty number of dependencies, some of which would not work on older versions of perl. In addition, some vendors did not include Email::Sender in their respective packaging systems, necessitating the use of CPAN.

As there are numerous modules relating to email delivery in CPAN, Log::Fine::Handle::Email now makes use of "interface" classes which can be used specify how email is delivered. Currently, the following classes are supported:

To maintain backward-compatibility with previous releases, Email::Sender is the default mechanism.

Subclassing

To sub-class this module, the following methods must be provided:

See the documentation below as well as the included interface modules for further details.

METHODS

new

Creates a new Log::Fine::Handle::Email subclass. By default, this will be a Log::Fine::Handle::Email::EmailSender class.

When writing an interface for Log::Fine::Handle::Email, this method must be sub-classed!

Parameters

Parameters are passed in hash-style, and thus may be passed in any order:

  • name

    [optional] Name of this object (see Log::Fine). Will be auto-set if not specified.

  • mask

    Mask to set the handle to (see Log::Fine::Handle)

  • subject_formatter

    A Log::Fine::Formatter object. Will be used to format the Email Subject Line.

  • body_formatter

    A Log::Fine::Formatter object. Will be used to format the body of the message.

  • header_from

    String containing text to be placed in "From" header of generated email.

  • header_to

    String containing text to be placed in "To" header of generated email. Optionally, this can be an array ref containing multiple addresses

  • email_handle

    Name of email_handle to use. The following modules are available:

    - Log::Fine::Handle::Email::EmailSender (EmailSender)

    Deliver email via the Email::Sender module

    - Log::Fine::Handle::Email::MIMELite (MIMELite)

    Deliver email via the MIME::Lite module

    By default Log::Fine::Handle::Email::EmailSender will be used

  • envelope

    [optional] hash ref containing envelope information for email:

    - to

    array ref containing one or more destination addresses

    - from

    String containing email sender

Additional parameters will be documented in each individual subclass.

msgWrite

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

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Log::Fine

You can also look for information at:

REVISION INFORMATION

$Id: 72add5537db39c25409ade70c1c6aaf398a6b5c1 $

AUTHOR

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

SEE ALSO

perl, Log::Fine, Log::Fine::Handle, Mail::RFC822::Address

COPYRIGHT & LICENSE

Copyright (c) 2011-2012 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.