I want to write a script to send emails via my server's SMTP server. The server requires SMTP authentication.
But I've problem completing this SMTP authentication. When the script is ran, the server gave out an error message: 535 Incorrect authentication data.
Could you kindly help fix the problem?
Thanks.
Here's the script (only listing the SMTP authentication portion)
#!/usr/bin/perl
use Net::SMTP_auth;
$smtpserver = 'mail.myserver.com';
my $ServerAccount = "mailbox\@myserver.com";
my $ServerPwd = "mb128com";
my $smtp = Net::SMTP->new($smtpserver, Hello => "myserver.com", Debug
+ => 1);
$smtp->auth('CRAM-MD5', '$ServerAccount', '$ServerPwd');
exit;
The followings is the output when the script is ran:
Net::SMTP>>> Net::SMTP(2.31)
Net::SMTP>>> Net::Cmd(2.29)
Net::SMTP>>> Exporter(5.58)
Net::SMTP>>> IO::Socket::INET(1.29)
Net::SMTP>>> IO::Socket(1.29)
Net::SMTP>>> IO::Handle(1.25)
Net::SMTP=GLOB(0x95167c0)<<< 220-server.myserver.com ESMTP Exim 4.69 #1 Wed, 16 Mar 2011 10:03:27 -0500
Net::SMTP=GLOB(0x95167c0)<<< 220-We do not authorize the use of this system to transport unsolicited,
Net::SMTP=GLOB(0x95167c0)<<< 220 and/or bulk e-mail.
Net::SMTP=GLOB(0x95167c0)>>> EHLO myserver.com
Net::SMTP=GLOB(0x95167c0)<<< 250-server.myserver.com Hello myserver.com
Net::SMTP=GLOB(0x95167c0)<<< 250-SIZE 52428800
Net::SMTP=GLOB(0x95167c0)<<< 250-PIPELINING
Net::SMTP=GLOB(0x95167c0)<<< 250-AUTH PLAIN LOGIN
Net::SMTP=GLOB(0x95167c0)<<< 250-STARTTLS
Net::SMTP=GLOB(0x95167c0)<<< 250 HELP
Net::SMTP=GLOB(0x95167c0)>>> AUTH PLAIN Q1JBTS1NRDUAQ1JBTS1NRDUAJFNlcnZlckFjY291bnQ=
Net::SMTP=GLOB(0x95167c0)<<< 535 Incorrect authentication data