Yes, you can write it locally, but afaik
Yes, you can write it locally, but afaik it can't actually be tested(unless you pass in the args yourself)
21 Replies
How do I configure the worker locally in Wrangler to indicate to Cloudflare that its a Email Worker?
Cloudflare Docs
Configuration - Wrangler · Cloudflare Workers docs
Use a
wrangler.toml
configuration file to customize the development and deployment setup for your Worker project and other Developer Platform …That seems to be for configuring regular Worker to be able to send emails to verified addresses but not for routing incoming emails?
It doesn't look like it
The config parser only shows options for
send_email
I just found in docs:
Cloudflare Docs
Runtime API · Cloudflare Email Routing docs
An EmailEvent is the event type to programmatically process your emails with a Worker. You can reject, forward, or drop emails according to the logic …
Sounds like any Worker can handle emails by adding this parameter
Yeah, you can write it in the Worker, but you can't configure which emails are routed to that Worker
If that is what you mean
What makes you say it cant be configured for routing?
Deciding which addresses are handled by a given Worker can only be done in the dashboard
Why else would you handle EmailEvent?
I mean that you can write code to handle incoming emails in a Worker, but to actually use that code, you need to connect some addresses to the Worker via the dash
Ok, thanks
I am trying to implement the Email Docs example for sending email
Any idea where there are docs for the package example is using?
import { EmailMessage } from 'cloudflare:email'
It's available via https://www.npmjs.com/package/@cloudflare/workers-types
npm
@cloudflare/workers-types
TypeScript typings for Cloudflare Workers. Latest version: 4.20240208.0, last published: 8 days ago. Start using @cloudflare/workers-types in your project by running
npm i @cloudflare/workers-types
. There are 113 other projects in the npm registry using @cloudflare/workers-types.Thanks, your saying there is no documentation only types?
Getting error locally: service core:user:driving-theory: Uncaught Error: No such module "cloudflare-internal:email
Presumably the local dev server does not yet support email?