First off, sending stuff directly to Sendmail can be extraordinarily dangerous. You have to be very dilligent about what you actually send in as data or you could have a very unpleasant surprise. Think about what might happen if someone passed in an email address as the string "hahascrewyou@suckers.com; rm -rf ~". You're not sending in that kind of stuff on the command line, but still, taint checking is your friend, as will be libraries such as Email::Valid. Despite all the precautions you might take, and the fact that you're not passing args on the command line but rather through stdin helps, it's still messy and you're better off using a wrapper library.

I use Mail::Mailer. Assuming that you're not passing around bogus data, here's the basic code snippet that I use.

my $mailer = Mail::Mailer->new('sendmail'); $mailer->open({From => 'someone@somewhere.com', To => 'recipient@someplace.com', Subject => 'this is the subject'}); print $mailer "this is the body!"; $mailer->close();

In reply to Re: Sending mail help by skyknight
in thread Sending mail help by debiandude

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.