Skip to content

Instantly share code, notes, and snippets.

@mpayetta
Created March 27, 2018 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpayetta/3e3ce035bc5eb8ac363afd900ddc791e to your computer and use it in GitHub Desktop.
Save mpayetta/3e3ce035bc5eb8ac363afd900ddc791e to your computer and use it in GitHub Desktop.
lambda-2.js
var aws = require("aws-sdk");
var nodemailer = require("nodemailer");
var ses = new aws.SES();
var s3 = new aws.S3();
exports.handler = function (event, context, callback) {
var mailOptions = {
from: "mauricio@xoor.io",
subject: "This is an email sent from a Lambda function!",
html: `<p>You got a contact message from: <b>${event.emailAddress}</b></p>`,
to: "mauricio@xoor.io",
// bcc: Any BCC address you want here in an array,
};
// create Nodemailer SES transporter
var transporter = nodemailer.createTransport({
SES: ses
});
// send email
transporter.sendMail(mailOptions, function (err, info) {
if (err) {
console.log("Error sending email");
callback(err);
} else {
console.log("Email sent successfully");
callback();
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment