Cloudflare Email Worker Auto Reply Example
Run Following Commands:
npm install -g wrangler
wrangler login
wrangler generate email-worker-auto-reply
Then It will ask:
✨ Created email-worker-auto-reply/wrangler.toml
✔ No package.json found. Would you like to create one? …
Answer YES.
✨ Created email-worker-auto-reply/package.json
✔ Would you like to use TypeScript? … no
Answer NO.
? Would you like to create a Worker at email-worker-auto-reply/src/index.js? › - Use arrow-keys. Return to submit.
None
Fetch handler
❯ Scheduled handler
Select Scheduled handler.
✔ Would you like us to write your first test? … no
Answer NO.
Then move to created directory, and move again to the src/
.
cd email-worker-auto-reply
cd src
Now you can code your project by modifying index.js
.
compatibility_flags = [ "nodejs_compat" ]
And run this:
npm install mimetext
Also If you wanna use Worker Logs, Then write these too
[observability.logs]
enabled = true
invocation_logs = false
npm run deploy
THAT'S IT!
Please go to Cloudflare Dashboard and configure your Email worker Route. Ensure your address will route to the worker you have deployed.
Open your domain's Email > EmailRouting
Click "Create Address" (It also works for Catch-All Address too!) And fill out form like this:
Click "Save" and if created successfully It will be like this:
Try sending email to [email protected]
and see:
If not recevied? Check Spam Folder!