Subject: | Net::SMTP Auth Doesn't work in Linux |
This was tested on Debian Etch.
Net::SMTP's auth feature does not work as documented in Linux. The
following works, but is nothing like what the documentation for this
module claims.
use Net::SMTP;
use MIME::Base64;
$smtp = Net::SMTP->new(
'smtp.MYEMAILSMTPSERVER.com' ,# may need a helo parameter here
on some servers
Timeout => 30,
Debug => 0,
);
$smtp->datasend("AUTH LOGIN\n");
$smtp->response();
# -- Enter sending email box address username below. We will use
this to login to SMTP --
$smtp->datasend(encode_base64('TYPEEMAILACCOUNTUSERNAMEHERE') );
$smtp->response();
# -- Enter email box address password below. We will use this to
login to SMTP --
$smtp->datasend(encode_base64('TYPEEMAILACCOUNTPASSWORDHERE') );
$smtp->response();
# -- Enter email FROM below. --
$smtp->mail('ENTEREMAILADDRESSFROM@DOMAINNAME.COM');
# -- Enter email TO below --
$smtp->to('ENTEREMAILADDRESSTOMAILTO@DOMAINNAME.COM');
$smtp->data();
#This part creates the SMTP headers you see
$smtp->datasend("To: Test\@DOMAINNAME.com\n");
$smtp->datasend("From: A Test Account <TEST\@DOMAINNAME.com>\n");
$smtp->datasend("Content-Type: text/html \n");
$smtp->datasend("Subject: A Test Message");
# line break to separate headers from message body
$smtp->datasend("\n");
$smtp->datasend("Here is my test message body");
$smtp->datasend("\n");
$smtp->dataend();
$smtp->quit;