Last active
December 21, 2015 03:19
-
-
Save timstermatic/6241437 to your computer and use it in GitHub Desktop.
Send an email using SES and Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load aws sdk | |
var aws = require('aws-sdk'); | |
// load aws config | |
aws.config.loadFromPath('config.json'); | |
// load AWS SES | |
var ses = new aws.SES({apiVersion: '2010-12-01'}); | |
// send to list | |
var to = ['[email protected]'] | |
// this must relate to a verified SES account | |
var from = '[email protected]' | |
// this sends the email | |
// @todo - add HTML version | |
ses.sendEmail( | |
{ | |
Source: from, | |
Destination: { ToAddresses: to }, | |
Message: { | |
Subject: { | |
Data: 'A Message To You Rudy' | |
}, | |
Body: { | |
Text: { | |
Data: 'Stop your messing around', | |
} | |
} | |
} | |
} | |
, function(err, data) { | |
if(err) throw err | |
console.log('Email sent:'); | |
console.log(data); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment