Created
August 23, 2019 07:37
-
-
Save flexelem/a965d01c1a6da17490df880d84993748 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var AWS = require("aws-sdk"); | |
var simpleParser = require("mailparser").simpleParser; | |
var s3 = new AWS.S3(); | |
exports.handler = async (event, context, callback) => { | |
console.log("Invoked Lambda"); | |
const mail = event.Records[0].ses.mail; | |
console.log("Mail"); | |
console.log(JSON.stringify(mail)); | |
var getParams = { | |
Bucket: "disposible-mails-bucket", | |
Key: "awesome_crypto_me/" + mail.messageId, | |
}; | |
let emailFromS3 = await s3.getObject(getParams).promise(); | |
let parsedEmail = await simpleParser(emailFromS3.Body); | |
console.log("parsedEmail Subject: " + parsedEmail.subject); | |
console.log("parsedEmail Body: " + parsedEmail.textAsHtml); | |
callback(null); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment