Steps to create Lambda function
1. Once you are able to generate the mails by running your code, then create a folder called nodejs and copy the node_modules folder into it.
2. Now zip the nodejs folder.
3. Now goto your aws lambda and create a Layer from the left-side navigation.
4. upload the zip file which you created.
5. Once saved, goto F*unctions* and click on create function .
6. Select Author from scratch option and give some relevant name to your function.
7. Select the runtime as Node Js version X (Select the version you wanted, like 14.x or 16.x).
8. Click on Advanced settings and check Enable function URL (which generates an auto url to trigger the function) and Select the Auth type you prefer.
9. Now click on create function button to create a new lambda function.
10. Now in the list of Lambda functions , choose your function and scroll down to Layers section
11. Click on Add a Layer -> Custom Layers
12. Choose the Layer which you created earlier and Click on Add
13. Now copy your code from your machine and paste it in index.js file between exports.handler = async (event) => { }
14. Now create a package.json file and copy the content from your local machine to this file.
15. Now click on Test and configure a simple test and run it.
16. Now the recipient will receive the mail.
17. In the Function overview, Copy the Function URL and paste it in your browser. That URL will trigger Lambda function.