Wow. Looks like more work to me.

I just don't see the value in re-inventing the wheel, or trying to remember every little implementation detail, each time I need to engineer something.
I don't see how boo_radley using Net::SMTP is reinventing the wheel. It's a great module, flexible and lets you send an email in as little as 8 or 9 lines.

just type perldoc Mail::Internet and you can read about how to use the smtpsend() method without worrrying about details regarding the SMTP protocol.
Have you tried perldoc Net::SMTP?

Personally, I find using Net::SMTP much easier, the mail headers really aren't that difficult: Probably easier than the method you are using. But it all depends on the application.

boo, here's how you can use here docs with Net::SMTP (and I don't necessarily see a problem with using a here doc for this, a template might be overkill):
use Net::SMTP; use strict; my $mailserver = '127.0.0.1'; my $smtp = Net::SMTP->new($mailserver); $smtp->mail('me@mydomainname.org'); $smtp->to('recipient@theirdomain.org'); $smtp->data(); $smtp->datasend(<<MYEMAIL); To: recipient\@theirdomain.org Subject: This is my subject An example of Net::SMTP with here docs See ya later! MYEMAIL $smtp->dataend() or print "Message sending failed!"; $smtp->quit;
In the above example, the mail() and to() methods actually tell the mailserver the recipient and sender, if you leave out the To: and From: (even subject:) headers, it shouldn't be a problem, but you still need the blank line before your real message begins. That's really all there is to remember, the rest is in the Net::SMTP docs.

$ perldoc perldoc
Updates: changed one or two words and qualified the opening "wow"

In reply to (here docs) Re: (2) Net::SMTP Implementation Details by $code or die
in thread Net::SMTP and templates/ here docs by boo_radley

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.