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( 'smtp.gmail.com', Hello => 'smtp.gmail.com', Port => 587, User => 'gmail userid', Password=> 'gmail password'); $mailer->mail('from@domain.com'); $mailer->to('targetuser@userdomain.com'); $mailer->data; $mailer->datasend("Subject:Email Subject"); $mailer->datasend("From:From Name<from@domain.com>n"); $mailer->datasend("To:targetuser@userdomain.com"); $mailer->datasend("This is the email body"); $mailer->dataend; $mailer->quit;