openec2 Article Description
Part 7
Configure an SES/S3 Bucket for forwarding email
The SES “Receiving rule” configurations below will place an email to admin@mydomain.com into your S3 bucket called mydomain.com.inbox.As you see, a lot has been done to get to this point.
The Lambda function will notify you there is an email in the bucket.
Obviously this is limited, but we need to know the configurations and processes involved.
After this, we can check if your have access to Node.js.16x which uses Javascript SDK1, and if so, you can use four different Lambda functions to forward you the email.
It is beyond me why Amazon AWS had not released functions to do the same in SDK2 with Node.js.20x. We can only work with what we’ve got.
We can however use a complicated Linux shell script to check for emails and use the “mutt” program to forward as an attachment to us. This scripting can get out of control quickly as we add complexity, so the example I will give later will forward to one person only.
From your PC send an email to admin@mydomain.com.
Then go to the S3 Bucket, e.g. mydomain.com.inbox and see if it arrives. Then click on it, download it, add a .eml file extension, and view it.
CloudWatch
If this has not worked, (or worked ok) we will now review the CloudWatch logs in your email region.e.g. Use the search bar for CloudWatch, then go there, and change the region in the top right corner to Oregon if using that region for Australia.
Go to: CloudWatch (Oregon) > Logs > Log groups
You should see a Log group under your Lambda function name, e.g. mydomain_com_notify.
Click on the left checkbox, then under the Action button, Edit retention setting(s). We don’t want to keep log entries forever, so perhaps change to a a few days.
After doing this, refresh to page to see the result.
Now click no the Log group URL, and you will see a Log stream. Click on it.
You will see a page with the Timestamp of all the processes that happened when receiving the email under that Lambda rule.
This is where you check for errors. If an error is obvious, you will know. If not, check your function for typos, or did you forget to add permissions to the S3 bucket.
The configurations I have given do work, but I have often found I missed a step or typed incorrectly.