Sending Mail Through Gmail with Perl
Last Updated: Mon, Jul 6, 2009We talked about some of the benefits of setting up an email server in Linux and how you can use python to send email. Now we are going to look at how you can send email from Perl.
The Code
use Net::SMTP::TLS;
my $mailer = new Net::SMTP::TLS(
'smtp.gmail.com',
Hello => 'smtp.gmail.com',
Port => 587,
User => 'username',
Password=> 'password');
$mailer->mail('[email protected]');
$mailer->to('[email protected]');
$mailer->data;
$mailer->datasend("Sent from perl!");
$mailer->dataend;
$mailer->quit;