ytjPerl has asked for the wisdom of the Perl Monks concerning the following question:

Hi folks, I have below code:
#!/usr/local/bin/perl use strict; use warnings; use Net::SMTP; my $smtp = Net::SMTP->new('smtp.xxxxx.com', Port => 25, Timeout => +20, Debug => 1 ); my $sender = my $user = 'username@xxxxx.com'; my $password = 'xxxxxxxx'; print "Trying to authenticate.."; $smtp->auth( $user, $password ) or die "could not authenticate\n"; my $receiver = 'username@xxxxx.com'; $smtp->mail( $sender ); $smtp->to( $receiver ); $smtp->data(); $smtp->datasend( "To: $receiver\n" ); $smtp->datasend( "From: $sender\n" ); $smtp->datasend( "Content-Type: text/html\n" ); $smtp->datasend( "Subject: Testing Net::SMTP" ); $smtp->datasend( "\n" ); $smtp->datasend( 'The body of the email' ); $smtp->dataend(); $smtp->message(); $smtp->quit();
my output is below
Net::SMTP>>> Net::SMTP(3.10) Net::SMTP>>> Net::Cmd(3.10) Net::SMTP>>> Exporter(5.72) Net::SMTP>>> IO::Socket::IP(0.38) Net::SMTP>>> IO::Socket(1.38) Net::SMTP>>> IO::Handle(1.36) Net::SMTP=GLOB(0x4b6c10)<<< 220 smtp.xxxxx.com ESMTP Net::SMTP=GLOB(0x4b6c10)>>> EHLO localhost.localdomain Net::SMTP=GLOB(0x4b6c10)<<< 250-smtp.xxxxx.com Net::SMTP=GLOB(0x4b6c10)<<< 250-8BITMIME Net::SMTP=GLOB(0x4b6c10)<<< 250-SIZE 20971520 Net::SMTP=GLOB(0x4b6c10)<<< 250 STARTTLS could not authenticate Trying to authenticate..
As I know, Net::SMTP uses Authen::SASL internally to do the authentication. Is there something I still need to configure in this Authenticate?

Replies are listed 'Best First'.
Re: Net::SMTP failed to authenticate
by 1nickt (Canon) on Oct 10, 2017 at 15:57 UTC

    Hi, please edit your post and put your output in code tags also.

    Your server appears to want encrypted connection but you are not using $smtp->starttls as shown in the doc for the module.


    The way forward always starts with a minimal test.
      Thanks, I've updated my post.