Send email using gmail in Perl

| By Webner

Here’s sample code to send email via Gmail SMTP server, which uses TLS (transport layer security):

#!/usr/bin/perl -w
use Net::SMTP::TLS;

my $mailer = new Net::SMTP::TLS(
Hello => '',
Port => 587,
User => 'gmail userid',
Password=> 'gmail password');

$mailer->datasend("Subject:Email Subject");
$mailer->datasend("From:From Name<>n");

$mailer->datasend("This is the email body");

Leave a Reply

Your email address will not be published. Required fields are marked *