When a user fills a contact form on your website (using ReCaptcha), and sends it, this function will check if the ReCaptcha token in the request is valid, and if so, will send you a personal email.
Your front end should send a POST request to your function's endpoint with a body payload in the form of
{
email: client_email_field,
subject: subject_field,
message: message_field,
token: frontend_recaptcha_token
}
Using AWS Lambda with NodeJS.
To customize your email, check the AWS SES API Reference.
If you're new to AWS Lambda you should start with
the setup guide
to install your AWS CLI, create an IAM user with the right permissions,
and run aws configure
.
Also create your Lambda function (referred to as my-function
below).
- Zip files: once unzipped you should immediately be in root.
- Run in the current directory:
aws lambda update-function-code --function-name my-function --zip-file fileb://your-zip-file.zip