This source code is to send transaction email with AWS lambda and set up SAM for local development
- Install serverless in local
https://serverless.com/framework/docs/getting-started/ - Set up aws credentials
https://serverless.com/framework/docs/providers/aws/guide/credentials/
- Install
Python.https://www.python.org/downloads/ - Install
Docker.https://docs.docker.com/install/ - Install
SAMin local .https://docs.aws.amazon.com/lambda/latest/dg/sam-cli-requirements.html
- After you install all of the above requirement, install require package
npm install. - Enter the source code folder. And then find the folder name
config. In that folder there is thedev.ymlfile (you can also create your environment as file name but you need to deploy your serverless package with your environment). In that file, changerecipient email,access_key_id,access_key_secretandregionto your desire email.
You can test this lambda function locally. In order to do that, follow this step.
- Enter your source code folder and type
sls sam export -o template.ymlin console , than all of you changes indev.ymlfile will sync toSAMdefination file. - Type
sam local start-apiand then you can test your lambda function in your local withhttp://localhost:3000/mail?username=TEST-INLOCAL&email=testinlocal0909@gmail.com
Then transaction email will send your email inbox.
I was create DKIM record for my domain and set up in SES console. If you want to test with your own domain, change sender value to your dkim identified email.
I was manually created metric logs for email open, click, send events. So, metrics can check manually on cloud watch dashboard.