Reference:
http://dipinkrishna.com/blog/2010/12/sending-emails-gmail-smtp-perl/
use Net::SMTP::TLS; # ActivePerl 5.14 才有
my $smtp = new Net::SMTP::TLS(
'smtp.gmail.com',
Port =>
587,
User =>
'sender@gmail.com',
Password=>
'Password',
Timeout =>
30
);
# -- Enter email FROM below. --
$smtp->mail('sender@gmail.com');
# -- Enter recipient mails addresses below --
my @recipients = ('recipient1@gmail.com', 'recipient2@yahoo.com');
$smtp->recipient(@recipients);
$smtp->bcc(@recipients);
$smtp->data();
#This part creates the SMTP headers you see
$smtp->datasend("To: recipient1\@gmail.com\n");
$smtp->datasend("From: Chandler \n");
$smtp->datasend("Content-Type: text/html \n");
$smtp->datasend("Subject: A Test Mail");
# line break to separate headers from message body
$smtp->datasend("\n");
$smtp->datasend("This is a test mail body");
$smtp->datasend("\n");
$smtp->dataend();
$smtp->quit;