Put this in your code after the "$smtp=Net::SMTP->new..." line:
 
     $smtp->auth($account,$password);
 
but the SMTP server needs to deal with SASL. Use values for $account and $password that authorize you for that server. My attempt at this failed until my service provider updated antiquated versions of the software.
 
Reference: Authen::SASL documentation
 
Dave

----- Original Message -----
Sent: Monday, December 19, 2005 12:37 PM
Subject: Sending email with authentication using Net::SMTP.

Hi,
 
Is anyone aware of any method of sending email with authentication using Net::SMTP or any other module. At this point I am experimenting trying to send email using perl v 5.6.1.
 
My ISP seems to require authentication when I run the script below with debug enabled.
 
Thanks,
 
Joydeep
 
 
#
# Test perl SMTP
#
use Net::SMTP;
$smtp = Net::SMTP->new("smtp.xyz.yahoo.com", Debug => 1); # connect to an SMTP server
die "Couldn't open connection: $!" if (!defined $smtp );
$smtp->mail( '[EMAIL PROTECTED]' ); # use the sender's address here
$smtp->to('[EMAIL PROTECTED]'); # recipient's address
$smtp->data(); # Start the mail
# Send the header.
$smtp->datasend("To: [EMAIL PROTECTED]");
$smtp->datasend("From: myname@xyz.net\n");
$smtp->datasend("Subject: Testing perl SMTP.\n");
$smtp->datasend("\n");
# Send the body.
$smtp->datasend("Testing perl SMTP....\n");
$smtp->dataend(); # Finish sending the mail
$smtp->quit; # Close the SMTP connection
print "Done!";


_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to