My option:

use Mail::Mailer; # Access sendmail/whatever sub send_email { my ( $error_msg, # input error msg $hostname, # name of this box for sending $prog_full_name, # prog path + name $contact_email, # contact email address $mailer, # mailer object $sender, # sender of email as specified in cfg file $subject, # subject line in email $body_text # actual email msg text ); # Assign input params $error_msg = $_[0]; # Get hostname anyway we can using Sys::Hostname; # tries syscall(SYS_gethostname), `hostname`, `uname -n` $hostname = Sys::Hostname::hostname(); # Get program full path name $prog_full_name = cwd()."/${0}"; # Set the fields required by Mailer... $contact_email = $cfg::params{'ADMIN_EMAIL'}; $sender = "$prog_full_name"; $subject = "$prog_full_name: Error trapped"; $body_text = "This is an automated message:\n\n". "$error_msg\n\n". "Regards,\n$prog_full_name at $hostname\n\n"; # ... and send it $mailer = Mail::Mailer->new(); $mailer->open({ From => $sender, To => $contact_email, Subject => $subject, }) or print "Can't open Mailer for send: $!\n"; print $mailer $body_text; close($mailer) or print "Can't close Mailer: $!\n"; } called as send_email("<your msg here>"); You can optionally specify the mail prog to be used (see the CPAN page +), or let it find one.
Cheers
Chris

In reply to Re: Simplest module for sending email by chrism01
in thread Simplest module for sending email by Anonymous Monk

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.