Net::SMTP 3.16 does not document a SOCKS or preconnected-socket constructor parameter. Wrapping a file descriptor with inherited new_from_fd does not run its SMTP constructor. A successful SOCKS connection supplies a stream, not an initialized mail session.

For plain SMTP, including a later STARTTLS upgrade, the server speaks first:

SOCKS: connection to smtp.example.net:587 succeeds

server: 220 smtp.example.net ready
client: EHLO client.example.net
server: 250-smtp.example.net
server: 250-STARTTLS
server: 250 AUTH ...

This is schematic; advertised extensions vary. The greeting may itself span multiple lines: a reply code followed by a hyphen continues the reply, while its final line terminates it. Consume the whole greeting before EHLO. Otherwise the client can read an old 220 when it expects EHLO's 250 and get out of step on a healthy connection.

Implicit TLS has another order: SOCKS connection, TLS handshake, then SMTP greeting inside TLS. STARTTLS begins with the readable greeting and EHLO, upgrades the stream and obtains capabilities again afterward.

The public constructor normally handles socket configuration, saved connection parameters and greeting information, the initial response and EHLO with HELO fallback where appropriate:

use Net::SMTP;

my $smtp = Net::SMTP->new(
    'smtp.example.net',
    Port    => 587,
    Hello   => 'client.example.net',
    Timeout => 30,
) or die "SMTP connection failed: $@";

$smtp->starttls()
    or die "STARTTLS failed: " . $smtp->message;

This public example uses STARTTLS and does not configure SOCKS. The server name selects the mail destination; Hello supplies client SMTP identity. For implicit TLS, use the documented SSL constructor option and the service's port.

SendHello => 0 suppresses automatic EHLO/HELO, not the greeting read or transport construction. Calling a line reader and then hello() is not a documented replacement for initialization either: Net::Cmd classifies its low-level response readers as protected subclass methods.

If SOCKS is mandatory, choose a client with a supported SOCKS interface or maintain an integration against the specific Net::SMTP version. Use the sequence above as its contract rather than copying private fields. A separate TCP adapter also needs deliberate TLS identity handling: the certificate must identify the real mail service, and proxy credentials remain separate from SMTP login.

Related articles