Amazon Simple Email Service on Windows – How To

Today Amazon announced AWS Simple Email Service (SES) beta.  SES is a great addition to Amazon Web Services, with it an organization can send marketing, transactional, subscription or system notification messages without have to manage their own messaging infrastructure.  And just like all other AWS services it’s pay-as-you-go – even free in some instances.

Soon as I received the announcement from Amazon I immediately set out to give it a try.  Since I normally use Windows that’s what I used for this.  I ran into a couple of minor problems but was easily able to resolve them and now I’m sending email through SES like a mad man. . .

Summary – Quick Steps
If you’re anxious to get started and don’t want any fluff here you go.  For everyone else read below.
  • Sign-up for SES
  • Install Perl
    • Install XML-LibXML via Perl Package Manager (instructions below)
  • Download AWS SES scripts
  • Setup “credentials” file (see below for details)
  • Get verified: ses-verify-email-address.pl -k creds.txt -v test@powercram.com
  • Send email: ses-send-email.pl -k creds.txt -s "Test One" -f test@powercram.com test@powercram.com

Prerequisites
Sign-up for SES.  If you already have an AWS account you’re one step closer, if not you’ll have to start there.

SES uses Perl scripts, therefore you must have Perl installed on your Windows machine.  I installed ActivePerl Community Edition.  Soon as that was done I ran the first SES script to get an email address verified but ran into my first problem – c:perlbin didn’t get added to my path by the installation (for some reason it added c:perlsitebin) so I had to do that manually (if you don’t know how to do this you probably shouldn’t be here anyway. . . )

Amazon Simple Email Service Scripts
Download the SES scripts and save to a useful location – I used d:awsses.  This download includes the following SES scripts:

  • ses-get-stats.pl – retrieves statistics about Amazon SES account usage
  • ses-send-email.pl – send email using Amazon SES
  • ses-verify-email-addresses.pl – verify email addresses to be used with Amazon SES

Next problem – when I ran ses-verify-email-address.pl --help I received the message: “Can't locate XML/LibXML.pm in @INC (@INC contains: C:/Perl/site/lib C:/Perl/lib.) at D:AWSSESses-verify-email-address.pl line 26.  BEGIN failed--compilation aborted at D:AWSSESses-verify-email-address.pl line 26.

After tooling around the web for a few minutes I realized I needed to manually install XML-LibXML.  This was easily done by opening the Perl Package Manager off the Start menu.  In there:

  • Click the “View All Packages” button or press Ctrl+1
  • Type libxml in the search box
  • Right-click on XML-LibXML and select Install . . .
  • Click File, Run Marked Actions or press Ctrl+Enter

Now when you run ses-verify-email-address.pl --help from the command line you can actually see the help for this command.

Credentials File for SES Commands
All of the SES scripts or commands require authentication to AWS, which makes sense.  You can save your credentials (both AWSAccessKeyId and AWSSecretKey) to a file, creds.txt and pass that to each script with the -k <filename> command.

Example credentials file:

AWSAccessKeyId=022QF06E7MXBSH9DHM02
AWSSecretKey=kWcrlUX5JEDGM/LtmEENI/aVmYvHNif5zB+d9+ct

Verify Email Address for SES
In order to send any email you must add & verify at least one email address to which you have access.  The verification is a two-step process.  First run the command: ses-verify-email-address.pl -k creds.txt -v test@powercram.com.  Amazon will send an email to that address with a link to click to finalize verification.

NOTE: Until you are granted production access to Amazon Simple Email Service you can only send to verified addresses. Click to Request for Production Access to Simple Email Service.  They say it may take up to 24 hours, but my access request was granted in about 30 minutes – now I can send to any address!


View List of Verified SES Addresses
By running the command ses-verify-email-address.pl -k creds.txt -l you are supposed to be able to view a list of verified addresses, however when I run this nothing is returned.  I did discover though that using the --verbose switch, ses-verify-email-address.pl -k creds.txt -l --verbose, I am able to view a list of verified addresses:

<listverifiedemailaddressesresponse xmlns="http://ses.amazonaws.com/doc/2010-12</p><p>01/">
 </listverifiedemailaddressesresponse>
<listverifiedemailaddressesresult></listverifiedemailaddressesresult>
    <verifiedemailaddresses></verifiedemailaddresses>
      <member>test@powercram.com</member>
 <responsemetadata></responsemetadata>



Send Email With SES
Finally we are ready to send email using the command ses-send-email.pl -k creds.txt -s "Test One" -f test@powercram.com test@powercram.com.  Press Enter then you can type the body of your message.  When that’s done press CTRL+Z, then Enter.  It will hesitate for a second or two while your credentials, etc. are verified and the message is queued.  Finally, check your email.

Summary
Amazon Simple Email Service looks to be a very useful tool and is a great addition to Amazon Web Services.  In just a few minutes you can be sending email through SES, and it can be adapted for myriad purposes.  Get started today and start emailing (useful messages – NO SPAM or other crap!).

Additional Info

See Also

12 thoughts on “Amazon Simple Email Service on Windows – How To

  1. I'm very thankful for this post. I was having the same issues of nothing showing up for -l flag and I was using Ctrl-D instead of Ctrl-Z and was wondering why emails weren't sending. THANKS!

  2. My perl scripts are showing all the time like I am not entering the correct arguments.
    [code]
    C:UsersZammyDesktopDispenrbin>ses-verify-email-address.pl -k creds.txt -v evgeni.i.petrov@gmail.c0m
    Begining of parse_argsBegining of validate_opts
    Usage:
    ses-verify-email-address.pl [–help] [-e URL] [-k FILE] [–verbose] -v
    EMAIL | -l | -d EMAIL

    C:UsersZammyDesktopDispenrbin>
    [/code]

  3. Great Guide!

    I installed XML Lib and I still can't get the Perl Scripts work.

    ——–

    root@MailWorks:~# /aws/ses/ses-get-stats.pl –help
    Can't locate SES.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at /aws/ses/ses-get-stats.pl line 23.
    BEGIN failed–compilation aborted at /aws/ses/ses-get-stats.pl line 23.

    ——

  4. @Kevin W read the README file included in the ses package, it gives 3 solututions to the "Can't locate SES.pm in @INC" problem.

    export PERL5LIB=/opt/third-party/amazon/ses (use the appropriate path)

    use lib '/opt/third-party/amazon/ses'; (again use correct path and place this in the pl scripts before the use SES line)

    perl -I/opt/third-party/amazon/ses ./ses-send-email.pl (once again use correct path)

  5. I just spent hours on this, it seems the latest perl 5.14… doesn't have Switch.pm, you need to get an old version, 5.12… grrrr

  6. Thanks. I tried this on Windows Server 2008 m1.small EC2 instance and works great. Thanks so much. I have verified that it sends to both Yahoo and Hotmail no problems.

    Thanks for this useful post.

Leave a Reply

Your email address will not be published. Required fields are marked *