Tuesday, June 10, 2008

Net::SMTP::TLS

For no apparent reason, I poked around mail client setup for gmail last night and I found it mentioned STARTTLS on their SMTP setup. Several month ago I didn't find any working Perl module to send email via google, so I decided to conduct a little search again using that keyword.

Enter Net::SMTP::TLS.
use Net::SMTP::TLS;
my $mailer = new Net::SMTP::TLS(
'smtp.gmail.com',
Hello => 'gmail.com',
Port => 587,
User => 'tracelogger@gmail.com',
Password=> 'pwd',
Timeout => 10,
Debug => 1,
);
$mailer->mail('tracelogger@gmail.com');
$mailer->to('anybody@world.com');
$mailer->data;
$mailer->datasend("To: anybody\@world.com\n");
$mailer->datasend("\n");
$mailer->datasend("Sent thru TLS!");
$mailer->dataend;
$mailer->quit;

No comments: