Cloudflare’s official Email Agent example was updated on October 27, 2026, according to the example documentation. It describes routing inbound email to an Agent and handling it through onEmail; it does not make a successful local execution proof of external delivery. For Cloudflare Email Agent testing, verify four separate stages: inbound routing, onEmail processing, reply sending, and receipt in a controlled inbox.
This week’s action: run one authorized test message through all four stages and save separate evidence for each. Do not mark the email loop complete just because a Worker ran or a send request returned without an error.
Developers: use this when connecting Cloudflare Agents SDK email handling to your own application.
QA engineers: use it to check parsing, replies, and resulting application state.
Technical leads: use it to separate test destinations and credentials, then record evidence the team can review.
Last updated October 28, 2026. Cloudflare-specific behavior was checked against the official Agents email channel documentation and Email Service local development guidance. Recheck these sources before release if the relevant API or project configuration has changed.
Treat the email loop as four separate acceptance gates
An email Agent test can pass one stage and fail at the next. A useful report names the stage that has evidence, rather than using a single “email passed” result.
| Gate | What the team is checking | Evidence to retain |
|---|---|---|
| Inbound routing | The message matched the intended route and reached the intended Worker or Agent entry point | Test message identifier, route configuration, and relevant routing or execution log |
onEmail handling |
The Agent received the test message and exposed the expected fields to application logic | Handler log or test assertion linked to the message |
| Reply sending | The application attempted to send the intended reply using its configured sending path | Send request outcome and a record of the expected reply |
| Controlled receipt | The reply arrived in an inbox the team can inspect | The received message, including its sender, recipient, subject, and body |
These gates answer different questions. A routing record does not prove the Agent parsed the body. A parsed body does not prove the business action succeeded. A send request does not prove a recipient’s mail system accepted the message, and acceptance by a sending service does not prove that a person’s inbox displayed it.
Cloudflare’s Agents email channel documentation and Email Agent example describe the Agent-oriented flow. The application still needs its own assertions for business outcomes, such as whether a request was recorded or a test account moved to the expected state. Keep that state check separate from mail transport evidence.
Developers: bind the test to the intended send path
Before sending anything, write down which code path the test exercises. An Agent may process an inbound message and then send a reply, while another test may call a sending method directly. Those tests do not establish the same behavior.
Check the application’s configured sender identity, the sending method used by the project, and the controlled recipient. Cloudflare documents the Workers sending API and its boundaries in the Email Sending Workers API reference. The exact method and binding available to a test must match the project’s actual configuration; do not assume that a code sample proves every deployment has the same settings enabled.
Associate the test request with the expected message. Use a test-only identifier in a field the application can safely inspect, such as a generated subject token or an application-level correlation value. Avoid placing credentials, access tokens, personal data, or production identifiers in message content. The value should let QA match the outgoing reply to the triggering request without exposing sensitive information.
A passing function call is narrow evidence. It can show that the application reached a send operation and that the operation did not surface a particular error. It does not independently establish that the destination server accepted the message or that the message arrived in the controlled inbox. Record the send outcome, then check receipt as a distinct gate.
Does local testing prove that an external mailbox received the email? No. Cloudflare’s local development guidance distinguishes local sending behavior from remote sending. A local result can support a code-path or simulation check, but receipt must be verified against a controlled external inbox when real delivery is part of the release criterion. See the local sending documentation linked above for the documented local and remote behavior.
Route maintainers: trace the inbound message to the right Agent
A message that never reaches the intended handler is not an onEmail parsing failure. First confirm that the test message is addressed to the expected domain or configured address. Then inspect the project’s inbound routing rules and confirm that the target route points to the intended Worker entry point and Agent resolver.
Cloudflare’s Email Routing address configuration documentation is the reference for the relevant routing setup. Compare the deployed configuration with the test environment rather than relying on a local file or an old deployment note. A route can be correctly written in source control but absent, different, or inactive in the environment under test.
Keep the diagnosis at the right boundary:
- If there is no evidence that the test message reached the configured route, investigate the address, route, and delivery path before changing Agent parsing code.
- If routing evidence exists but the Agent entry point has no corresponding execution, inspect the Worker target, resolver mapping, and environment configuration.
- If the Agent entry point ran, move to handler-level checks. Do not report a route failure just because a later application assertion failed.
For each test, retain enough context to identify the message without copying sensitive content into general logs. A message identifier, test address, timestamp, and relevant route outcome are usually more useful than a full dump of the email. Restrict access to raw messages when they contain private or operational details.
QA engineers: verify onEmail parsing against the test message
A useful onEmail test starts with one controlled message whose expected values are known. Check that the handler receives the intended sender and recipient, the relevant headers, and the parsed body. Confirm that these values correspond to the message used for this run, not merely to a previous fixture or a hard-coded example.
How can QA show that onEmail received this particular test message? Match the incoming message to a unique test case using a non-sensitive identifier, then assert the expected fields at the handler boundary. The Cloudflare Email Agent example is useful for understanding the documented Agent flow; the project’s own test should establish whether its current message reached its own handler.
Do not collapse parsing and business processing into one assertion. For example, an email body may parse successfully while failing a validation rule, failing to update an application record, or being rejected by a downstream service. Test those outcomes separately:
- Handler assertion: the Agent received the expected message fields.
- Parser assertion: the application extracted the expected values from the message.
- Business assertion: the application performed the intended action or returned the expected failure.
- Reply assertion: the response content and destination match the test case.
Include negative cases in the test plan. A missing expected field, an unfamiliar header, or content the parser cannot interpret should produce the application’s intended behavior—not an unhandled exception or a misleading “success.” The correct result depends on the application contract. Document it before running the test so the QA result is not decided after seeing the output.
How should parsing be matched to the current test message? Use an identifier that travels with the test case and is visible at the relevant processing boundary. Compare the parsed sender, recipient, headers, and body with the expected fixture for that run. If the application normalizes or transforms content, assert both the raw input boundary and the normalized value the business logic consumes.
Security owners: constrain reply routes and test credentials
Replies need a safe destination. Confirm which address the application uses for a reply, whether the Agent’s routing information affects that destination, and whether the project applies an optional signature mechanism. The official Agents email channel documentation describes the documented channel behavior, but the exact security properties depend on the deployed configuration and application implementation.
Do not infer a security guarantee from the presence of a header, signature option, or route setting alone. Verify what the project validates, where it validates it, and what happens when validation fails. A test should include the relevant rejection behavior if the application relies on it.
Keep test credentials separate from production credentials. Limit access to any secret used for sending, and avoid copying secrets into fixtures, logs, screenshots, or issue reports. Test data should also be synthetic or otherwise authorized. The VuSend privacy policy is available for teams evaluating privacy considerations around a test inbox, but it does not replace the team’s own review of what its application sends or retains.
Use this decision path to choose the right evidence
Choose the test method based on the claim the team needs to make. A local or simulated test can be sufficient for code behavior, but it cannot stand in for a controlled external receipt check.
- If the question is whether application code builds the expected message, use a local or automated test and assert the message content and send-path invocation. Report this as a code-path result, not as delivery.
- If the question is whether inbound routing reaches the Agent, send a controlled inbound message and inspect routing and entry-point evidence. Do not stop at a parser unit test.
- If the question is whether
onEmailparses a real inbound message, use a controlled message and verify the handler’s observed fields against that message. - If the release claim includes a customer-visible reply, send through the configured remote path and inspect the reply in a controlled external inbox.
- If the flow depends on a business change, verify the application state separately from the inbox. A received message alone does not prove that the intended record or workflow changed.
This decision path prevents overclaiming. Teams can still use fast local checks early in development, then reserve the external inbox run for the acceptance gate that actually requires it. Consult the local development sending guidance linked above when deciding what the local path proves in the current setup.
Release owners: assemble a reviewable evidence bundle
A release decision should make it possible for another engineer to reproduce the conclusion. Keep the evidence concise and tied to the same test request:
- The environment and route configuration relevant to the run.
- The test message identifier and expected parsing result.
- The routing and Agent execution evidence.
- The send operation outcome and expected reply content.
- Proof that the controlled inbox received the reply, if external receipt is part of the claim.
- The resulting application state, if the flow is meant to change one.
- Any failure, retry, or fallback behavior observed.
Avoid a screenshot of one successful log line as the sole artifact. It often cannot show whether the log belongs to the current message, whether the reply was sent, or whether it was received. A short record that links the same test identifier across handler logs, send evidence, inbox inspection, and application state is more useful than a large unfiltered log export.
A reply needs its own receipt check. An inbound message arriving at the Agent proves nothing about the outbound path. Likewise, a send operation reporting success is not a substitute for inspecting the controlled destination when the acceptance criterion is actual receipt. Note what the team observed and what remains unverified.
Keep the test inbox separate from user data
Use a controlled destination that the team can access and that does not belong to an unrelated user. Avoid putting real customer details in test messages. This reduces accidental exposure in logs, shared QA reports, and screenshots, and makes the test easier to repeat safely.
Temporary inboxes are one option for short-lived registration, notification, or reply checks. They are not appropriate when the test requires a durable address, later account recovery, ongoing correspondence, or a guaranteed reply path. If inbox lifetime affects the test, review the VuSend inbox expiry guidance before choosing a destination. Do not assume an address will remain available beyond the service’s stated behavior.
For a one-off check of your own test email, VuSend can provide a no-registration, ready-to-use temporary inbox, keeping the test separate from a primary mailbox and its unrelated messages. It is an observation option, not a delivery guarantee: confirm the message actually arrived, and use a durable controlled mailbox for workflows that require long-term access or replies. Start from the VuSend temporary inbox service only when its current capabilities fit the test’s requirements.
Use a separate address for your next short-term verification
VuSend creates a temporary inbox with a clear countdown right on the page. Copy the address, receive your code, and let the email and address be cleared on schedule when you are done.
Open temporary inbox