Thanks for the advise. It's a project I'm working on for a small charity in my spare time, so I didn't feel too bad about asking if anyone wanted to share their existing code. In the spirit in which I asked the question, here's what I wrote:
package Log::Dispatch::Email::Emailstuff; use strict; use warnings; use Log::Dispatch::Email; use base qw( Log::Dispatch::Email ); use Email::Stuff; sub send_email { my $self = shift; my %p = @_; Email::Stuff->to (join ',', @{$self->{to}}) ->from ($self->{from}) ->subject ($self->{subject}) ->text_body ($p{message}) # ->attach_file ('choochoo.gif') ->using ('SMTP', Host => 'smtp.server.goes.her +e.com') ->send; } 1; __END__ =head1 NAME Log::Dispatch::Email::Emailstuff - Subclass of Log::Dispatch::Email th +at uses the Email::Stuff module =head1 SYNOPSIS use Log::Dispatch::Email::Emailstuff; my $email = Log::Dispatch::Email::Emailstuff->new ( name => 'email', min_level => 'emerg', to => [ qw( foo@bar.com bar@baz.org ) ], subject => 'Oh no!!!!!!!!!!!', ); $email->log( message => 'Something bad is happening', level => 'emer +g' ); =head1 DESCRIPTION This is a subclass of Log::Dispatch::Email that implements the send_email method using the Email::Stuff module. =head1 METHODS =over 4 =item * new This method takes a hash of parameters. The following options are valid: =over 8 =item * name ($) The name of the object (not the filename!). Required. =item * min_level ($) The minimum logging level this object will accept. See the Log::Dispatch documentation on L<Log Levels|Log::Dispatch/"Log Levels" +> for more information. Required. =item * max_level ($) The maximum logging level this obejct will accept. See the Log::Dispatch documentation on L<Log Levels|Log::Dispatch/"Log Levels" +> for more information. This is not required. By default the maximum is the highest possible level (which means functionally that the object has no maximum). =item * subject ($) The subject of the email messages which are sent. Defaults to "$0: log email" =item * to ($ or \@) Either a string or a list reference of strings containing email addresses. Required. =item * from ($) A string containing an email address. This is optional and may not work with all mail sending methods. This option works with Email::Stuff. NOTE: The Mail::Sendmail module requires an address be passed to it to set this in the mail it sends. We pass in 'LogDispatch@foo.bar' as the default. =item * using Specifies the Email::Send driver that you want to use to send the emai +l, and any options that need to be passed to the driver at the time that we send the mail. Alternatively, you can pass a complete mailer object (which must be an Email::Send object) and it will be used as is. =item * buffered (0 or 1) This determines whether the object sends one email per message it is given or whether it stores them up and sends them all at once. The default is to buffer messages. =item * callbacks( \& or [ \&, \&, ... ] ) This parameter may be a single subroutine reference or an array reference of subroutine references. These callbacks will be called in the order they are given and passed a hash containing the following ke +ys: ( message => $log_message, level => $log_level ) The callbacks are expected to modify the message and then return a single scalar containing that modified message. These callbacks will be called when either the C<log> or C<log_to> methods are called and will only be applied to a given message once. =back =item * log_message( level => $, message => $ ) Sends a message if the level is greater than or equal to the object's minimum level. =back =head1 AUTHOR Dave Rolsky, <autarch@urth.org> wrote Log::Dispatch::Email and Brent Shaw, <brent.shaw.ucf@gmail.com> made it work with Email::Stuff =cut

Cheers,

Brent

-- Yeah, I'm a Delt.

In reply to Re^2: Subclassing Log::Dispatch::Email by dorko
in thread Subclassing Log::Dispatch::Email by dorko

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.