Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-25 23:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found