Skip to content

Instantly share code, notes, and snippets.

@diegofcornejo
Last active January 22, 2019 04:45
Show Gist options
  • Save diegofcornejo/fa733aac2cdcf039fcc10c5db5b81bae to your computer and use it in GitHub Desktop.
Save diegofcornejo/fa733aac2cdcf039fcc10c5db5b81bae to your computer and use it in GitHub Desktop.
Send email with AWS SES in Lambda
"use strict";
const AWS = require('aws-sdk');
const SES = new AWS.SES({ apiVersion: '2010-12-01' });
module.exports = {
send: function() {
var params = {
Destination: {
ToAddresses: [
"[email protected]"
]
},
Message: {
Body: {
Html: {
Charset: "UTF-8",
Data: "Here your Message in <b>HTML</b>"
},
Text: {
Charset: "UTF-8",
Data: "Here your Message in plain text"
}
},
Subject: {
Charset: "UTF-8",
Data: "Here you Subject"
}
},
Source: "[email protected]",
};
SES.sendEmail(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
}
};
'use strict';
const AWS = require('aws-sdk');
const EMAIL = require('./aws_ses_lambda.js');
exports.handler = (event, context, callback) => {
//HERE YOUR CODE
EMAIL.send();
callback(null, ':)');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment