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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.