Email Workers seems to now be enabled. Soft launch I guess?
The documentation is still a little sparse. This is some notes on what I found in case it is useful to others.
It appears you can only forward to " Destination addresses". You can not use the aliases defined in “Custom addresses” at this point. Also it is not clear how to forward to more than one destination address.
KV namespaces in Email Workers seems fully broken. I defined a KV name space, added it to the worker’s SETTINGS > Variables > KV Namespace Bindings. Looks good. Code is even simpler than what I use in Web Workers. But I get exceptions that the KV variable “DEST” does not exist. When I go into the worker again, the Namespace is somehow no longer associated with the Worker.
I have not been able to figure out how the “Email Trigger” tab works. When I fill stuff in and press the button I get no feedback.
Is there somewhere to report these issues, or is this it for a Free account?
Summary: Shows great potential, but still a bit unripe
Cloudflare’s Discord in the Email Routing channel might be your best bet for feedback/help, and many other community members may be able to help you as well.
You can set up routes/custom addresses to send to workers, and then those workers can forward to any verified destination address you have.
If you want to forward an email to more then one destination address, just have the worker call the message.forward method twice, i.e
await message.forward(“[email protected]”)
await message.forward(“[email protected]”)
You cannot forward to two workers, if that’s what you were asking.
Re: KV Issues, are you perhaps confusing Module Worker and Service Worker Syntax? Service Workers (using addEventListener) have bindings in the global space, Module Worker bindings are on the Env passed into the fetch
The Email Trigger tab only works if you load the worker code first from the normal workers tab / quick edit, and then navigate to the Email Trigger tab without reloading
This may be part of the issue. So I changed my KV get to Module Worker syntax
destEmail = await env.DEST.get(key);
But I still get an exception when it runs, and the binding in the Settings tab still disappears following the runtime exception. The disappearing binding is odd.
Strange it was getting removed though. I tested editing in the Email Trigger tab thinking that may have removed it, but my email worker with a KV binding is still bound.
The only other thing I can think is that if you’re pushing code from wrangler as well, it overrides your bindings/would remove them.
There is definitely a problem with dashDOTcloudflareDOTcom and how it handles two separate sessions logged into the same account.
The binding of the KV store to an Email Worker is removed if I edit the Javascript source code of the worker while another session is logged in (but is on a computer that is locked and is not being used). Follows is a photo of how it should be configured, but this config just disappears somehow.