We 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('from@domain.com');
$mailer->to('to@domain.com');
$mailer->data;
$mailer->datasend("Sent from perl!");
$mailer->dataend;
$mailer->quit;

Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.