Send emails with Perl

Perl is a general-purpose interpreted programming language, with powerful design features for text manipulation, nowadays it is mostly used for system administration and web development, its CPAN, wich stands for Comprehensive Perl Archive Network has more than 20,000 third party modules. Bellow, you can find a snippet I use to deliver emails with Perl using Gmail SMTP server.


use strict;
use warnings;
use Email::Send::SMTP::Gmail;

my ($mail,$error) = Email::Send::SMTP::Gmail->new(
    -layer => 'ssl',
    -port  => '465',
    -smtp  => '',
    -login => '',
    -pass  => 'password'

die "session error: $error" if $mail ==-1;

    -to          => '',
    -subject     => 'Greetings',
    -body        => 'Sent from PERL',
    -attachments => '/home/john/Documents/john.doe/test.txt'