Skip Menu |

This queue is for tickets about the Net-SMTPS CPAN distribution.

Report information
The Basics
Id: 123006
Status: resolved
Priority: 0/
Queue: Net-SMTPS

People
Owner: TOMO [...] cpan.org
Requestors: mbradshaw [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: STARTTLS fails
When invoked with starttls, the call to starttls() never occurs. In the call to $obj->supports('STARTTLS'), Net::SMTP returns an empty string, which evaluates to false. The call should be defined( $obj->supports('STARTTLS') )
On Mon, 11 Sep 2017 02:54:55 GMT, MBRADSHAW wrote: Show quoted text
> When invoked with starttls, the call to starttls() never occurs. > > In the call to $obj->supports('STARTTLS'), Net::SMTP returns an empty > string, which evaluates to false. > > The call should be defined( $obj->supports('STARTTLS') )
Thanks for your report. That is true the call to starttls() never occurs, but the reason is the other. Net::SMTPS->new($host, doSSL => 'starttls',...) do STARTTLS command and its procedures in itself, and connection has already been TLS'ed when new() returns. So that all the later call of starttls() (defined in Net::SMTP(~3.10) do nothing because the connection already in STARTTLS state. For the reference, the call of Net::SMTP's starttls() starts like, sub starttls { my $self = shift; $ssl_class or die $nossl_warn; $self->_STARTTLS or return; ... and may be returned here. and about Perl thing, $obj->supports('STARTTLS') is True when you call like (of course server must replies offerings) ---------- use Net::SMTPS; my $smtp= Net::SMTPS->new('mail.test.com:587', Debug => 1); if ($smtp->supports('STARTTLS')) { print "True\n"; } else { print "False\n"; } ----------- See https://perldoc.perl.org/functions/exists.html BTW, recent Net::SMTP supports SSL/STARTTLS already, I should up my module to date.
Hi Tomo, Thanks for the quick response. Your comment about supports returning true doesn't appear to be correct. Running your test script against smtp.fastmail.com gives the following output. Net::SMTPS>>> Net::SMTPS(0.06) Net::SMTPS>>> IO::Socket::IP(0.39) Net::SMTPS>>> IO::Socket(1.38) Net::SMTPS>>> IO::Handle(1.36) Net::SMTPS>>> Exporter(5.72) Net::SMTPS>>> Net::SMTP(3.10) Net::SMTPS>>> Net::Cmd(3.10) Net::SMTPS=GLOB(0x7f9498942730)<<< 220 smtp.fastmail.com ESMTP ready Net::SMTPS=GLOB(0x7f9498942730)>>> EHLO localhost.localdomain Net::SMTPS=GLOB(0x7f9498942730)<<< 250-smtp.fastmail.com Net::SMTPS=GLOB(0x7f9498942730)<<< 250-PIPELINING Net::SMTPS=GLOB(0x7f9498942730)<<< 250-SIZE 71000000 Net::SMTPS=GLOB(0x7f9498942730)<<< 250-ENHANCEDSTATUSCODES Net::SMTPS=GLOB(0x7f9498942730)<<< 250-8BITMIME Net::SMTPS=GLOB(0x7f9498942730)<<< 250 STARTTLS False Running against Net::SMTP gives the same output. Net::SMTP>>> Net::SMTP(3.10) Net::SMTP>>> Net::Cmd(3.10) Net::SMTP>>> Exporter(5.72) Net::SMTP>>> IO::Socket::IP(0.39) Net::SMTP>>> IO::Socket(1.38) Net::SMTP>>> IO::Handle(1.36) Net::SMTP=GLOB(0x7feb7e92f020)<<< 220 smtp.fastmail.com ESMTP ready Net::SMTP=GLOB(0x7feb7e92f020)>>> EHLO localhost.localdomain Net::SMTP=GLOB(0x7feb7e92f020)<<< 250-smtp.fastmail.com Net::SMTP=GLOB(0x7feb7e92f020)<<< 250-PIPELINING Net::SMTP=GLOB(0x7feb7e92f020)<<< 250-SIZE 71000000 Net::SMTP=GLOB(0x7feb7e92f020)<<< 250-ENHANCEDSTATUSCODES Net::SMTP=GLOB(0x7feb7e92f020)<<< 250-8BITMIME Net::SMTP=GLOB(0x7feb7e92f020)<<< 250 STARTTLS False As you can see from the debug output, the server does support STARTTLS. print Dumper ($smtp->supports('STARTTLS')); returns $VAR1 = ''; # empty string If I change the test in the example to read if (defined $smtp->supports('STARTTLS')) { It outputs True as expected.
On Mon, 11 Sep 2017 10:30:41 GMT, MBRADSHAW wrote: Show quoted text
> Hi Tomo, > > Thanks for the quick response. > > Your comment about supports returning true doesn't appear to be > correct. Running your test script against smtp.fastmail.com gives the > following output.
Show quoted text
> As you can see from the debug output, the server does support > STARTTLS. > > print Dumper ($smtp->supports('STARTTLS')); > returns $VAR1 = ''; # empty string > > If I change the test in the example to read > if (defined $smtp->supports('STARTTLS')) { > > It outputs True as expected.
Indeed. I have mistakenly checked in old (0.05) environment ;-<) which is, Net::SMTPS>>> Net::SMTPS(0.05) Net::SMTPS>>> IO::Socket::INET6(2.65) Net::SMTPS>>> IO::Socket(1.31) Net::SMTPS>>> IO::Handle(1.28) Net::SMTPS>>> Exporter(5.64_01) Net::SMTPS>>> Net::SMTP(2.31) Net::SMTPS>>> Net::Cmd(2.29) Net::SMTPS>>> IO::Socket::INET(1.31) Net::SMTPS=GLOB(0x7ffd3910a210)<<< 220 smtp.fastmail.com ESMTP ready Net::SMTPS=GLOB(0x7ffd3910a210)>>> EHLO localhost.localdomain Net::SMTPS=GLOB(0x7ffd3910a210)<<< 250-smtp.fastmail.com Net::SMTPS=GLOB(0x7ffd3910a210)<<< 250-PIPELINING Net::SMTPS=GLOB(0x7ffd3910a210)<<< 250-SIZE 71000000 Net::SMTPS=GLOB(0x7ffd3910a210)<<< 250-ENHANCEDSTATUSCODES Net::SMTPS=GLOB(0x7ffd3910a210)<<< 250-8BITMIME Net::SMTPS=GLOB(0x7ffd3910a210)<<< 250 STARTTLS True $VAR1 = '^M'; OK, I have updated as you mentioned above. I will release as 0.07 later. Thanks for your advice.