Here's the section of the Node Lambda function that gets the email stored in S3. How do I just get the 'text/plain' content from the returned data object?
Do I need to include an NPM email parsing dependency with the lambda function (uploaded as .zip) or should I use some regex in the lambda to get the section I want? If so what would that look like?
exports.handler = function(event, context, callback) {
var sesNotification = event.Records[0].ses;
// Retrieve the email from your bucket
s3.getObject({
Bucket: bucketName,
Key: "ses/"+sesNotification.mail.messageId
}, function(err, data) {
if (err) {
console.log(err, err.stack);
callback(err);
} else {
data
}
});
};
It would be safer to use
mailparser
package for parsing.