# Test email delivery locally

Use this mode when preview email is insufficient for a delivery test. Identity and submitted application state stay local, but Cloudflare sends a real message and records its delivery lifecycle.

## Prerequisites

Use an inbox you control and a Cloudflare grant with the required zone and Email Sending access. Stop any stack already using port 8787\. First verify the normal [local sign-in flow](/stormtrust/engineering/operations/local-development/).

1. From the repository root, replace the example address with your test inbox.  
```sh  
make dev-email EMAIL_TO=you@example.com  
```  
The launcher checks the active sending domain and limits the remote Email binding to that recipient. It uses `local-dev@stormtrust.net` as the sender.
2. Enter sign-in through `http://stormtrust.localhost:8787` and trigger the verification flow for that inbox. Open the message on the same computer; its link returns to ` auth.stormtrust.localhost`.
3. Complete verification and confirm the browser returns through the local gateway. Check the delivery result without sharing verification links or tokens. The production auth outbox ignores events from this local sender.
4. Stop the launcher with `Ctrl+C`. Use ` make dev` to return to preview email.

If Wrangler reports missing zone or Email Sending access, refresh the approved local OAuth grant using the owning toolchain, then retry:

```sh
bash scripts/apps/pnpm.sh auth exec wrangler login
```

Do not substitute production auth keys or expand the recipient restriction to work around a failed test.
