Skip to content

Instantly share code, notes, and snippets.

@timstermatic
Last active December 21, 2015 03:19
Show Gist options
  • Save timstermatic/6241437 to your computer and use it in GitHub Desktop.
Save timstermatic/6241437 to your computer and use it in GitHub Desktop.
Send an email using SES and Node.js
// 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