As already suggested, there is a good selection of modules on CPAN for handling email.

You should consider limiting access to the script and, if possible, the potential recipients of the emails that this script can send email to - especially if it's publically accessable.

If your script takes arguments for the recipient and the message content, and doesn't do any sort of checking, it could be used to spam people - and it would all appear to come from your email account.

If you plan on using the script to allow people to email you from your website for example, hardcode your email address as the recipient in the script - there's no need for the script to send to anyone else.

As far as I'm concerned, this is one time where flexibility shouldn't be at the top of your list.
Figure out exactly what the script has to do, and ensure it can do no more.

Hope that helps,

Baz.


In reply to Re: bad email code? by BazB
in thread bad email code? 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.