develooper Front page | perl.module-authors | Postings from February 2005

Mail::Preconfigured

Thread Next
From:
Eric Wilhelm
Date:
February 28, 2005 20:52
Subject:
Mail::Preconfigured
Message ID:
200502282257.22514.ewilhelm@sbcglobal.net
Oh wise and potent module namers...

I have a module that uses Net::SMTP_auth and basically implements the 
following interface:

  # This assumes settings (such as mymail@mydomain)
  # are found in your ~/.mrmailer.conf (or /etc/...)
  my $mail = Mail::MrMailer->new()
  ... # productive stuff
  if($error) {
    # you'll be the only one to get this:
    $mail->maildie("error happened:  $error");
  }
  # you'll get a bcc of this:
  $mail->send_msg({to => $recip, cc => $mail->var('boss')}, 
    join("\n", 
      "Everything is okay.",
      "I'm taking tomorrow off.", "",
      "--Eric", ""
      ));

This is really intended for cron and other fully-automatic 
(webserver/daemon triggered) jobs where you want mail to be sent via an 
external smtp server (and don't want to mess with sendmail.)  Because 
of the YAML config file support, you can define the owner's (your) 
address and smtp username/password info in a single place instead of in 
every script.

The usual questions apply:
  How useful is this?
  What should I name it?

I've looked at:
  Email::Send::SMTP::Auth
    too messy, no config-file support
  Mail::Send*
    too full-service/procedural

I've also played with the idea of defining some signal handlers or other 
IO-magic which would allow you to send mail on a standard die() call or 
maybe use some kind of severity threshold to only send warnings which 
go above a given threshold.  (but maybe that's another module?)

Maybe it goes in IO::?

--Eric
-- 
"It is a mistake to allow any mechanical object to realize that you are 
in a hurry." 
                                      -- Ralph's Observation
---------------------------------------------
    http://scratchcomputing.com
---------------------------------------------

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About