1 Answer
- Newest
- Most votes
- Most comments
0
Modify your Lambda function to differentiate between emails received directly (from external senders like Gmail) and emails sent by the Lambda function itself. You can achieve this by:
Adding a Custom Header
Before forwarding the email in Lambda, append a custom header (e.g., X-Lambda-Forwarded: true).
Filtering Incoming Emails
Modify your Lambda function to check for this header.
If the header exists, skip storing the email in S3 to prevent it from triggering the function again.
Relevant content
asked 2 years ago
- AWS OFFICIALUpdated a year ago

Your solution doesn't work. Since the personal email lives in the custom domain, all incoming email will be sent to this domain, hence captured by SES. In my settings, the Lambda function is at the tail end of the email-processing pipeline. So it goes like this: sender -> SES -> save the email to S3 -> S3 trigger a putObject event -> the Lambda function is invoked on putObject event, put the filter header in the email and forward to personal email address -> the email doesn't go to the receiver but comes back to SES again because of the aforementioned traffic rule, so the email ends up in S3 again. I'm thinking my solution for this problem might be using an SMTP relay.