Skip to content

Instantly share code, notes, and snippets.

@jonathanrodriguezs
Last active June 27, 2020 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanrodriguezs/18a2395a7843a555ac1d111244a89632 to your computer and use it in GitHub Desktop.
Save jonathanrodriguezs/18a2395a7843a555ac1d111244a89632 to your computer and use it in GitHub Desktop.
Send email via Gmail SMTP (SSL)
#!/usr/bin/perl
use strict;
use warnings;
use Email::Send::SMTP::Gmail;
my ($mail,$error) = Email::Send::SMTP::Gmail->new(
-layer => 'ssl',
-port => '465',
-smtp => 'smtp.gmail.com',
-login => 'john.doe@gmail.com',
-pass => 'password'
);
die "session error: $error" if $mail ==-1;
$mail->send(
-to => 'jane.doe@gmail.com',
-subject => 'Greetings',
-body => 'Sent from PERL',
-attachments => '/home/john/Documents/john.doe/test.txt'
);
$mail->bye;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment