View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Christopher M. Fuhrman > Log-Fine > Log::Fine::Handle::Email



Annotate this POD


Open  1
View/Report Bugs


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!

    my $bodyfmt = Log::Fine::Formatter::Template
        ->new( name     => 'template2',
               template => $msgtmpl );

    # Create an Email Handle
    my $handle = Log::Fine::Handle::Email
        ->new( name => 'email0',
               subject_formatter => $subjfmt,
               body_formatter    => $bodyfmt,
               header_from       => "",
               header_to         => [ "" ],
               envelope          =>
                 { to   => [ "" ],
                   from => "",
                   transport =>
                     Email::Sender::Transport::SMTP->new({ host => '' }),

    # Register the 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.

Implementation Details

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:

See Email::Sender::Manual::Quickstart for further details.

Email Address Validation

Log::Fine::Handle::Email will validate each email addresses prior to use. Upon initilization, L::F::H::E will search for and use the following email address validation modules in the following order of preference:

Should neither Mail::RFC822::Address nor Email::Valid be found, then a default regex will be used which should work for most instances. See CAVEATS for special considerations.

Constructor Parameters

The following parameters can be passed to Log::Fine::Handle::Email->new();



Sends given message via Email::Sender module. Note that "_error" in Log::Fine will be called should there be a failure of delivery.

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


Note that the Email::Valid module does not use the same checking algorithms as Mail::RFC822::Address. Email addresses considered valid under one module may not be considered valid under the other. For example, under Mail::RFC822::Address, jsmith@localhost is considered a valid address while Email::Valid will reject it. Consider researching each module prior to making a determination as to which is acceptable for your environment and needs.


Please report any bugs or feature requests to bug-log-fine at, or through the web interface at 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:


Christopher M. Fuhrman, <cfuhrman at>


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


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

syntax highlighting: