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.