---
title: "Read test mail in the dev inbox"
description: "Read the mail a deployment outside production sent to Resend's test addresses, back through Resend's own emails API: in a page with useSandboxInbox or from the CLI, so a demo, a preview or an end-to-end test can sign in by code."
canonical_url: "https://nuxt-backend.dev/docs/develop/dev-inbox"
---
# Read test mail in the dev inbox

> Read the mail a deployment outside production sent to Resend's test addresses, back through Resend's own emails API: in a page with useSandboxInbox or from the CLI, so a demo, a preview or an end-to-end test can sign in by code.

Version: nuxt-backend 0.6.x · Tab: Develop · Kind: how-to · Status: experimental

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

- [Try it live in the playground](https://nuxt-backend.dev/login)
- [API reference](https://nuxt-backend.dev/docs/reference/api/use-sandbox-inbox)
- [Source](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-sandbox-inbox.ts)

Open the mail your app sent in development without a mailbox. Outside production, email runs in test mode, and only Resend's test addresses receive it, such as `delivered@resend.dev` and its `+label` forms. Nobody can open those mailboxes, so the dev inbox reads what was sent to one back through Resend's emails API. A demo, a preview deployment or an end-to-end test can then finish an email-code sign-in.

The dev inbox keeps no copy of its own: Resend's log of sent email is the inbox. It needs `EMAIL_API_KEY`, lists what one test address received in the last hour, and answers nothing on production, nor on a deployment whose `BACKEND_ENVIRONMENT` is unset. Without a key, nothing is sent, and on `development` the sign-in codes print in your terminal instead ([Develop with real sandboxes](https://nuxt-backend.dev/docs/develop/sandboxes#sign-in-with-codes-in-the-terminal)).

<note>

The dev inbox is experimental ([STABILITY.md](https://github.com/qruto/nuxt-backend/blob/main/STABILITY.md)): how far back it reads and the code it extracts may change in a minor release.

</note>

## Read it from the command line

A coding agent, a script or an end-to-end test reads the inbox with the CLI, on your dev deployment:

```bash
npx nuxt-backend inbox                                    # delivered@resend.dev
npx nuxt-backend inbox delivered+e2e-42@resend.dev --json
```

It reads once and exits: it prints the newest sign-in code, or nothing while none has arrived, so a test polls it until a code appears. With `--json`, it prints `{ address, deployment, messages: [{ from, subject, receivedAt, code }], code }`, never a body. It needs `EMAIL_API_KEY` on the deployment, targets the deployment `.env.local` names, and refuses production ([`inbox`](https://nuxt-backend.dev/docs/reference/cli#inbox)).

An end-to-end test asks for a code with a fresh test address on `/login`, then reads it here and types it in ([Run end-to-end tests](https://nuxt-backend.dev/docs/develop/testing/e2e#sign-in-from-a-test)).

## Read it in a page

Publishing the inbox to the browser is opt-in, twice over. The deployment opts in with `EMAIL_DEV_INBOX=1`: `npx nuxt-backend dev` sets it on a dev deployment, and `env push` never carries it to a preview or production. `npx nuxt-backend deploy --sandbox` sets it on a demo on `BACKEND_ENVIRONMENT=sandbox`, and `doctor --prod` accepts it there while it flags it on a live production. On a preview, or a sandbox you set up by hand, set it with `npx convex env set EMAIL_DEV_INBOX 1`. Without it, or on production, `getSandboxInbox` answers an empty inbox. Then add `getSandboxInbox` to the `email.api` re-export in `backend/email.ts`, and read it with `useSandboxInbox`:

```ts [backend/email.ts]
export const { getEmailStatus, getSandboxInbox, previewEmails, sendEmailPreview } = email.api
```

```vue [app/pages/demo-login.vue]
<script setup lang="ts">
// A fresh label per visitor keeps one visitor's mail out of another's inbox.
// useState keeps the same address on the server and in the browser.
const address = useState('demo-address', () => `delivered+${crypto.randomUUID()}@resend.dev`)
const inbox = useSandboxInbox({ address })
</script>

<template>
  <p>Sign in as {{ address }}</p>
  <AuthForm />
  <p v-if="inbox.code.value">Your sign-in code: {{ inbox.code.value }}</p>
</template>
```

`useSandboxInbox({ address })` returns:

- `messages`: the address's ten newest messages, newest first. The newest carries its `text` and `html`; the rest, only their sender, subject and time.
- `latest`: the newest one.
- `code`: the first six-digit code in it.
- `isLoading`, and `error` when the inbox could not be read.

It asks again every ten seconds while the page is open, and pauses while the address is empty. The playground's sign-in page reads a visitor's code this way.

Production never answers, whatever the variable says, and `npx nuxt-backend doctor` warns when it is left set there ([`deployment-email-dev-inbox`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#deployment-email-dev-inbox)).

<warning>

The reader is public and needs no sign-in, since a visitor reads it before they have an account. Anyone who knows a test address can read its mail and sign in as it. Publish it only where every account is a throwaway test one, generate labels nobody can guess, and never show one person's address to another. The reader shows no mail for an address whose account is an administrator's or [passkey-only](https://nuxt-backend.dev/docs/build/auth/sign-in#passkey-only-accounts), so a code read there never signs in to one: protect an account that matters by turning on passkey-only sign-in. The command line runs as you, and reads every address. Resend's log is the whole team's: give a deployment that publishes the reader a Resend team (and key) of its own, or its readers also see what your other deployments sent to the same test address. A read is one list of the newest sent emails and one retrieval of the newest message, every ten seconds for each open page, and the backend answers reads within five seconds from the list and the body it read before, whatever address they ask, against Resend's limit of 10 requests a second for a team.

</warning>

## Related

- [Develop with real sandboxes](https://nuxt-backend.dev/docs/develop/sandboxes#email-on-resends-test-addresses): the test addresses and the events they send.
- [Get email into inboxes](https://nuxt-backend.dev/docs/build/email/delivery/deliverability): leave test mode on production.
- [Run end-to-end tests](https://nuxt-backend.dev/docs/develop/testing/e2e): a Playwright sign-in with the code from `inbox --json`.
- [`useSandboxInbox`](https://nuxt-backend.dev/docs/reference/api/use-sandbox-inbox): the composable's generated reference.


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
