mail-worker
is a Cloudflare Worker that send emails using AWS SES.
Install all dependencies.
yarn
POST
/
(sends email to recipient(s))
name type data type description to required string[]
an array of recipient's email address from required string
sender's email address subject required string
email subject html required string
email content
http code content-type response 200
text/plain
Email sent!
400
text/plain
Invalid request!
500
text/plain
Failed to send email!
curl $MAIL_WORKER_ENDPOINT -H 'Content-Type: application/json' -d \ '{ "to": ["[email protected]"], "from": "[email protected]", "subject": "test", "html": "test" }'
To use any sender email, the email must first be verified. The verification will require the following environment variables. You may populate your environment with the following.
echo AWS_REGION=$AWS_REGION >> .env
echo AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID >> .env
echo AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY >> .env
Now, pipe your email as stdin to the verify-email
script.
echo $EMAIL_ADDRESS | yarn verify-email