Skip to content

Latest commit

 

History

History
62 lines (44 loc) · 2.47 KB

README.md

File metadata and controls

62 lines (44 loc) · 2.47 KB

mail-worker

main.yml

mail-worker is a Cloudflare Worker that send emails using AWS SES.

Development

Install all dependencies.

yarn

Usage

POST / (sends email to recipient(s))

Parameters

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

Responses

http code content-type response
200 text/plain Email sent!
400 text/plain Invalid request!
500 text/plain Failed to send email!

Example cURL

curl $MAIL_WORKER_ENDPOINT -H 'Content-Type: application/json' -d \
'{
  "to": ["[email protected]"],
  "from": "[email protected]",
  "subject": "test",
  "html": "test"
}'

Verify Email

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