How to access an email body when invoking a Lambda Function upon receiving an email through SES?

0

I have a rule to invoke a Lambda Function when SES receives an email. This works fine. I pass Lambda the event as an argument in the handler and assign an email constant a value of "event.Records[0].ses.mail". When console logging this value, I cannot find the content body showing the actual body of the email. Instead, I can only view the subject, recipient, sender, etc. How do I access the body of an email sent to my domain?

This is my current handler:

const handler = async (event) => {
        // Get Email
        const email = event.Records[0].ses.mail // console logs fine, but has no content/email body

       // Get Body
       const body = ?
}

已提问 1 年前956 查看次数
1 回答
1
已接受的回答

Instead of triggering on the event of receiving an email in SES, why not trigger when the received email is saved in S3?
Set up an event trigger in the S3 bucket for receiving emails and run Lambda.
When the event is triggered, you can check the body of the email by using Lambda to get_object the object.
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/with-s3-example.html#with-s3-example-create-trigger

profile picture
专家
已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则