Use Send Email when the worker should send outbound email with explicit address rules
The send_email binding lets Workers send outbound email through Cloudflare Email Routing.
Send Email is a real binding surface in Devflare, and it is worth documenting separately from inbound handlers so the two flows do not get blurred together.
That distinction matters because outbound email is a binding you call from worker code, while inbound email handling is a worker event surface with its own test helper story.
- Config key
- Authoring shape
- Best for
- Outbound notification email and controlled email-sending paths from worker code
Use the binding from application code
After Devflare generates the worker env, import from and keep the first Send Email path close to the route, handler, or service method that needs it.
Keep this first path small enough that the config, env binding, and user-visible behavior are easy to review together.
Send one email from the worker
Local and Remote Support
Devflare can run useful Send Email application behavior locally for ordinary development and tests. Cloudflare still owns production limits, quotas, billing, and deployed account behavior.
Outbound local support; distinct from inbound email event testing. Start locally with plus ; that lane should cover the normal Send Email application flow without requiring a Cloudflare connection.
Use Cloudflare when the assertion depends on deployed limits, account state, lifecycle behavior, billing, or other production-only Send Email details.
Decide what a local send actually does
The top-level block answers one question for and : what happens to a message a worker hands to a Send Email binding. It never reaches deployed output.
The mode is never inferred from credentials. A populated , or the matching environment variable, leaves the run in until something explicitly selects — otherwise a suite that happened to run on a machine with real mail settings would start sending real mail.
requires , and every address in , , and is rewritten to it at the binding boundary, before transport, on the assembled MIME. Worker code cannot route around it, which is the point: a developer laptop holding a production token still cannot reach a real user.
Every relayed message is stamped with a marker header ( by default, renameable via ). The inbound poller skips anything carrying it, so pinning outbound mail at the same mailbox you poll does not feed each message straight back into the worker.
| Mode | What happens | Reach for it when |
|---|---|---|
| (default) | The message is recorded in the outbox. Nothing leaves the machine. | Always, unless you have decided otherwise. |
| Recorded, then every recipient is rewritten to and the message is delivered over SMTP from the host process. | You want to look at the real rendered mail in a real inbox. | |
| Devflare stands aside; the runtime binding performs the send, which is real Cloudflare delivery when the binding is . | You are deliberately exercising the hosted path. |
Capture is the default on purpose
Every knob below is inert until says otherwise. Set it in the config you keep out of CI, or through , and leave the default alone everywhere else.
Relay local mail to one inbox, and poll that inbox back in
Environment overrides for local email
Every field has an environment variable, so a machine can carry mail settings without the repo carrying them. is the only one that changes what happens.
- with no endpoint or no pinned recipient fails at start-up rather than quietly falling back to .
- The inbound poller stays off until or says otherwise; it reads, and by default marks, real mail.
- Both SMTP and IMAP use implicit TLS only — on 465 and on 993.
| Variable | Overrides |
|---|---|
| — , , or | |
| (the pinned recipient) | |
When this binding fits best
- Use Send Email when the worker needs to send notifications or transactional messages outward.
- Leave a binding unrestricted () when the account sends to arbitrary recipients from a verified domain.
- Keep address restrictions explicit so the worker cannot quietly send anywhere it pleases.
- Do not confuse outbound send-email bindings with inbound email processing handlers.
Testing path
- and are mutually exclusive in one binding definition.
- The local story for outbound email is strong, but it should still be documented separately from inbound email event helpers.
- Preview resource lifecycle does not manage email addresses the way it manages storage resources, because the binding compiles the address rules as-is.
Outbound is not inbound
and handler tests are connected by the domain, but they are different contracts and should be documented that way.
Open the next page when you need it
Subpage
Send Email internals
InternalsCheck emitted Wrangler , preview behavior, and Cloudflare-specific details.
Subpage
Testing Send Email
TestingPick the plus path first, then move to remote checks only when the test needs them.
Subpage
Send Email example
ExampleCopy a fuller application path when the quick example is too small.