I think Net::SMTP is used as a general mail sender much more often than it should. People are usually using it on Windows because there's no /usr/sbin/sendmail or to gain Windows compatibility for their code even if sendmail(1) is available.

By using Net::SMTP instead of MIME::Lite, Mail::Sendmail or Mail::Sender we usually lose:

flexibility when specifying email addresses
Net::SMTP recipients() method (or to() alias) accepts only plain emails. You just cannot take a To: line from a mail template and pass it to Net::SMTP, because Net::SMTP will choke on $smtp->to("sales@domain.com, check@domain.com") or $smtp->to("Sales <sales@domain.com>"). You people usually don't want to parse RFC822 email headers, do you?

ability to send complex emails (MIME)
Net::SMTP only allows you to send raw data. If you have enough time to do MIME by hands, I admire and envy you. But if you use MIME::Entity or MIME::Lite, why even bother with Net::SMTP? These modules send their results to the Internet just perfectly (using Net::SMTP internally if you specify SMTP delivery).

ability to send mail in SMTP-challenged environments
These includes not only dialup systems but also uucp-connected (there're some). In spite of the fact that most of the time such systems have a local smtp-server running which will handle queueing and the like, there's a case which hit me just recently.

My hosting provider runs cgi-scripts inside a sandboxed environment without ip-connectivity to Internet. (And that's a good security practice for all free hostings out there). And the provider allows sending mails only via sendmail(1) just to be able to impose restrictions on sending mail.

Even if these facts may seem of little importance to the majority of Perl programmers out there, Net::SMTP gives practically no advantages over other mail-sending modules, which are usually capable of using either SMTP connection or sendmail(1). The only advantage I see is sending several mails via a single connection for speed. In this case your (very specialized) program is more of an SMTP client than a mail-sending entity. And that's the very case Net::SMTP is perfect to serve, but such cases are very rare (are you a bulk sender?).

And it's sad for me to see such posts as Net::SMTP v local MTA or SMTP Modules that are both Win32 and Unix compliant when people intentionally choose Net::SMTP over other alternatives due to Windows lacking sendmail(1).

Update: I just found the relevant item in perlfaq9. It confirms my strong negative feelings about too wide-spread use of Net::SMTP.


In reply to Net::SMTP shortcomings if used as a general mail sending module by kappa

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.