Skip to content

Instantly share code, notes, and snippets.

@tacitochaves
Created June 25, 2014 03:53
Show Gist options
  • Select an option

  • Save tacitochaves/2fbb27e18410bc9c2fc9 to your computer and use it in GitHub Desktop.

Select an option

Save tacitochaves/2fbb27e18410bc9c2fc9 to your computer and use it in GitHub Desktop.
Emailing from Perl script - Net::SMTP::TLS
#!/usr/bin/env perl
#
# This program will make the redundancy between two internet links.
#
# Author: Tácito Chaves - 2014-06-17
# e-mail: chaves@tchaves.com.br
# fone: (98) 8123-8153 / 8857-9777
use strict;
use warnings;
use Net::SMTP::TLS;
my $smtp = new Net::SMTP::TLS(
'smtp.gmail.com',
Port => 587,
User => 'remetente@gmail.com',
Password => '123@mudar',
Timeout => 30,
);
# -- Enter email FROM below. --
$smtp->mail('remetente@gmail.com');
# -- Enter recipient mails addresses below --
my @recipients = ( 'destinatario1@exemple.com', 'destinatario2@exemple.com' );
$smtp->recipient(@recipients);
$smtp->data();
# This part creates the SMTP headers you see
$smtp->datasend("To: destinatario1\@exemple.com\n");
$smtp->datasend("From: remetente\@gmail.com\n");
$smtp->datasend("Content-Type: text/html \n");
$smtp->datasend("Subject: A Test Mail");
# line break to separate headers from message body
$smtp->datasend("\n");
$smtp->datasend("This is a test mail body");
$smtp->datasend("\n");
$smtp->dataend();
$smtp->quit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment