Skip to content

Instantly share code, notes, and snippets.

@jeffjohnson9046
Created September 8, 2016 05:23
Show Gist options
  • Save jeffjohnson9046/3488642c7fa8d4083386e1e69b5526d2 to your computer and use it in GitHub Desktop.
Save jeffjohnson9046/3488642c7fa8d4083386e1e69b5526d2 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
#-----------------------------------------------------------------------------------------------------------------------------------------
# File: aws-email-sender.pl
#
# Desc: Send an email via Amazon SES.
#
# Code for this gist came from this article: https://blog.vpetkov.net/2015/11/29/sending-html-emails-with-perl-to-a-remote-smtp-with-tls/
# To install the packages/libraries required to support this script, the following commands were used:
#
# cpan Email::Sender
# cpan Email::Stuffer
# cpan Email::Sender::Transport::SMTPS
#-----------------------------------------------------------------------------------------------------------------------------------------
use strict;
use Email::Sender::Simple qw(sendmail);
use Email::Stuffer;
use Email::Sender::Transport::SMTPS ();
my $smtpServer = 'email-smtp.us-west-2.amazonaws.com';
my $smtpPort = 25;
my $smtpUser = '[the user name from the credentials generated by SES]';
my $smtpPassword = '[the password from the credentials generated by SES]';
my $email = Email::Stuffer->from('[email protected]')->to('[email protected]')->subject('Test from Email::Sender')->html_body("This is a <strong>test</strong>")->email;
my $transport = Email::Sender::Transport::SMTPS->new({
host => $smtpServer,
port => $smtpPort,
ssl => "starttls",
sasl_username => $smtpUser,
sasl_password => $smtpPassword,
});
sendmail($email, { transport => $transport });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment