Basically I think bless-ing your socket as a Net::SMTP object will work, but have a look at the Net::SMTP->new method for some additional initialization that goes on.
use Net::SMTP; # create your own socket however you want my $sock = IO::Socket::INET->new(...); net_smtp_from_existing_socket($sock) or die "couldn't do it, sorry"; sub net_smtp_from_existing_socket { my $sock = shift; my $hello = shift; # the optional hello message bless $sock, 'Net::SMTP'; $sock->autoflush(1); # can set $sock->debug here if you want unless ($sock->response() == CMD_OK) { $sock->close(); return undef; } (${*$sock}{'net_smtp_banner'}) = $sock->message; (${*$sock}{'net_smtp_domain'}) = $sock->message =~ /\A\s*(\S+)/; unless ($sock->hello($hello || "")) { $sock->close(); return undef; } $sock; }
Alternatively, use Net::SMTP->new to create the socket - the returned object itself is an IO::Socket::INET object.

In reply to Re: Pass a socket to a Net:SMTP object by pc88mxer
in thread Pass a socket to a Net:SMTP object by sheepfunk

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.