Simple script for AWS lambda that allows to turn POST HTTP request into an email. Can be used to send emails from your JS code. For example you can collect all form data on static website with JS and send it to your email via serverless endpoint.
- Create AWS lambda function with URL, no authorisation and no CORS check
- Upload copy code of
serverless_mailer.pyfile into yourlambda_function.py - Rename
settings.example.initosettings.iniand customise with your SMTP and destination settings - Upload to AWS into same folder as
lambda_function.py - Deploy, Enjoy
- Send POST request to the AWS Lambda URL
- Body must be in JSON format and
Content-Typeshould beapplication/json - Body must contain
subjectandcontentfields - Body can contain
tofield with email from allowed emails list - Make sure that you send requests from one of allowed origins