|
| 1 | +--- |
| 2 | +"miniflare": minor |
| 3 | +--- |
| 4 | + |
| 5 | +Capture locally sent and received emails, along with forwarding and reply activity and metadata, for inspection through the Local Explorer email API. |
| 6 | + |
| 7 | +Miniflare now captures locally sent and received emails, including forwarding, reply, rejection, and exception activity. The following endpoints are available below `/cdn-cgi/local/explorer/api` while `wrangler dev` is running: |
| 8 | + |
| 9 | +- `POST /local/email/routing/send?worker=<name>` sends a test email to a Worker's `email()` handler. |
| 10 | +- `GET /local/email/routing?worker=<name>` lists emails received by a Worker. |
| 11 | +- `GET /local/email/routing?email_id=<message-id>&worker=<name>` returns a received email and its handler activity. |
| 12 | +- `GET /local/email/sending?worker=<name>` lists emails sent through a Worker's `send_email` bindings. |
| 13 | +- `GET /local/email/sending?email_id=<message-id>&worker=<name>` returns a sent email. |
| 14 | + |
| 15 | +For example, send and then inspect a test email against a Worker named `my-worker`: |
| 16 | + |
| 17 | +```sh |
| 18 | +curl -X POST \ |
| 19 | + "http://localhost:8787/cdn-cgi/local/explorer/api/local/email/routing/send?worker=my-worker" \ |
| 20 | + -H "Content-Type: application/json" \ |
| 21 | + --data '{ |
| 22 | + "from": "sender@example.com", |
| 23 | + "to": ["inbox@example.com"], |
| 24 | + "subject": "Local test", |
| 25 | + "text": "Hello from Local Explorer" |
| 26 | + }' |
| 27 | + |
| 28 | +curl \ |
| 29 | + "http://localhost:8787/cdn-cgi/local/explorer/api/local/email/routing?worker=my-worker" |
| 30 | +``` |
| 31 | + |
| 32 | +List endpoints support `per_page` and opaque `cursor` query parameters. File paths logged by the `send_email` binding are asynchronous debugging artifacts and should not be used to synchronize after `send()` resolves. Email handler exceptions are logged when structured local delivery reports an exception outcome. |
| 33 | + |
| 34 | +When email content exceeds the local storage row budget of approximately 2 MB, the email is delivered in full but the Local Explorer capture is truncated to fit. Detail responses identify each truncated sent email, received email, or reply in the top-level `messages` array with warning code `10604`; for example: |
| 35 | + |
| 36 | +```json |
| 37 | +{ |
| 38 | + "messages": [ |
| 39 | + { |
| 40 | + "code": 10604, |
| 41 | + "message": "Displayed received email content was truncated during local capture. The complete message was still delivered to the Worker." |
| 42 | + } |
| 43 | + ] |
| 44 | +} |
| 45 | +``` |
0 commit comments