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 年前檢視次數 957 次
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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南