The Net:SMTP module works really well and doesn't rely on sendmail so if you switch to a different MTA the script still works. Unlike calling sendmail from a script, Net::SMTP also allows you to use a remote MTA such as one at your ISP. This is a bit of a script (hopefully modified correctly) that should show the basics. The original script I wrote runs as a cron job and fetches my stock quotes from Yahoo and sends them to my cell phone every day at market close. Note, the start of the text should include the standard To:, From: and Subject: lines explicitely stated with a blank line at the end as shown below. Replace localhost with your ISP's MTA if appropriate. -Steve
use Net::SMTP; # Get ready to send messages via SMTP $thetext = "From: me\@myself.org\n"; $thetext .= "To: you\@yourself.com\n"; $thetext .= "Subject: Some Stuff\n"; $thetext .= "\n"; # Send the message and disconnect $smtp=Net::SMTP->new('localhost'); $smtp->mail("me\@myself.org"); $smtp->recipient("you\@yourself.com"); $smtp->data($thetext); $smtp->quit;

In reply to RE: Mail Question by Anonymous Monk
in thread Mail Question 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.