feat: add Cloudflare Email Workers support alongside ForwardEmail
Both email providers now work in parallel on the same Worker:
- ForwardEmail: existing POST /api/inbound webhook (unchanged)
- Cloudflare Email Routing: native `email` handler using postal-mime
New files:
- src/lib/email-processor.ts shared business logic (feed lookup,
sender allowlist, KV storage) extracted from inbound.ts
- src/lib/cloudflare-email.ts Cloudflare `email` handler; parses
raw RFC 2822 email with postal-mime, delegates to processEmail()
- src/lib/email-processor.test.ts 9 unit tests
- src/lib/cloudflare-email.test.ts 5 integration tests
Also fixes pre-existing CORS 204 response: c.text("", 204) →
c.body(null, 204) to match Hono's EmptyStatusCode constraint.
To enable: configure Cloudflare Email Routing with a catch-all rule
`*@domain.com` pointing to this Worker.
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
This commit is contained in:
1 parent
29446a2aac
commit
093efe7fc9
8 files changed
+477
-167
No files matched your search
@@ -30,6 +30,7 @@
|
||||
"dependencies": {
|
||||
"feed": "^5.2.0",
|
||||
"hono": "^4.11.7",
|
||||
"postal-mime": "^2.7.4",
|
||||
"zod": "^4.3.6"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user