Created
October 2, 2017 21:52
-
-
Save pbzona/7b8ebcf276bdc378f455ddeb04eb56d9 to your computer and use it in GitHub Desktop.
Event handler for serverless contact form
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
exports.handler = (event, context, callback) => { | |
console.log('Received event:', JSON.stringify(event, null, 2)); | |
var emailObj = JSON.parse(event.body); | |
var params = getEmailMessage(emailObj); | |
var sendEmailPromise = sesClient.sendEmail(params).promise(); | |
var response = { | |
statusCode: 200 | |
}; | |
sendEmailPromise.then(function(result) { | |
console.log(result); | |
callback(null, response); | |
}).catch(function(err) { | |
console.log(err); | |
response.statusCode = 500; | |
callback(null, response); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment