---
title: "Email"
description: "Auth emails sent for you, your own sends from server code, templates, test mode and live delivery tracking, through Resend inside the backend component."
canonical_url: "https://nuxt-backend.dev/docs/email"
---
# Email

> Auth emails sent for you, your own sends from server code, templates, test mode and live delivery tracking, through Resend inside the backend component.

Email goes through [Resend](https://resend.com), nested inside the `backend` component, so sending works once the `EMAIL_*` variables are set. The package sends the sign-in and account emails for you, your server code sends its own through `setupEmail`, and every message sent through the component is tracked until it is delivered, bounces or fails.

## What sends what

<table>
<thead>
  <tr>
    <th>
      Email
    </th>
    
    <th>
      Sent by
    </th>
    
    <th>
      Customize with
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Sign-in, verification and email-change codes, welcome, delete-account, workspace invitation
    </td>
    
    <td>
      The package, from the auth flow
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/email/templates">
        <code>
          templates
        </code>
      </a>
      
       on <code>
        setupEmail
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Gift notification
    </td>
    
    <td>
      The package, when a gift is paid
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/email/templates">
        <code>
          templates
        </code>
      </a>
      
       on <code>
        setupEmail
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Everything else
    </td>
    
    <td>
      Your server code, through <code>
        email.send
      </code>
    </td>
    
    <td>
      Your own HTML or text, or a provider-hosted template
    </td>
  </tr>
</tbody>
</table>

The package's own emails go out through the same `setupEmail` instance: `setupAuth` and `setupBilling` take it as their `email` option, so its templates restyle them all. For drips, [`defineEmailSequence`](https://nuxt-backend.dev/docs/email/engagement/sequences) sends delivery-tracked steps from a durable workflow. For marketing, the scaffolded `email.ts` ships segments, contacts and broadcasts as internal actions.

## How it fits together

1. **Configure.** Set `EMAIL_API_KEY` and `EMAIL_FROM`; the scaffolded `convex.config.ts` forwards the `EMAIL_*` variables to the component. Until a key is set, sends do nothing, and a sign-in code or an invitation to a real address is [refused up front](https://nuxt-backend.dev/docs/email/deliverability#codes-and-invitations-that-would-not-arrive); a dev deployment gets `NUXT_BACKEND_LOG_OTP=1`, which prints the codes to the console instead. See [Environment](https://nuxt-backend.dev/docs/email/sending#environment).
2. **Send.** From an action, `email.send(ctx, options)` enqueues a durable email and resolves to its id. From a mutation or a workflow step, call `components.backend.email.send` directly. See [Sending](https://nuxt-backend.dev/docs/email/sending#sending).
3. **Test, then go live.** Test mode is the default: the provider delivers only to its test addresses, such as `delivered@resend.dev`. Verify a sending domain in Resend, then set `EMAIL_TEST_MODE=false` (see [Get email into inboxes](https://nuxt-backend.dev/docs/email/deliverability)). While test mode is on, the [sandbox inbox](https://nuxt-backend.dev/docs/email/sandbox-inbox) keeps an hour's copy of mail sent to those addresses, so a demo or an end-to-end test can still finish an email-code sign-in.
4. **Track.** Point a Resend webhook at `/email/events` and store `EMAIL_WEBHOOK_SECRET`. `useEmailStatus` then follows each message from `queued` to `delivered`, `bounced` or `failed`, and `events` hooks on `setupEmail` react to bounces and complaints. See [Delivery tracking](https://nuxt-backend.dev/docs/email/delivery-tracking).

## In this section

<card-group>
<card icon="i-lucide-send" title="Sending" to="https://nuxt-backend.dev/docs/email/sending">

Set up `setupEmail`, send from your server code, use the sandbox inbox, and configure the `EMAIL_*` variables.

</card>

<card icon="i-lucide-layout-template" title="Templates" to="https://nuxt-backend.dev/docs/email/templates">

Every email the package sends, how to restyle any of them in one place, and how to preview them.

</card>

<card icon="i-lucide-mail-check" title="Delivery tracking" to="https://nuxt-backend.dev/docs/email/delivery-tracking">

The `/email/events` webhook, `useEmailStatus`, and per-event hooks for bounces and complaints.

</card>

<card icon="i-lucide-inbox" title="Get email into inboxes" to="https://nuxt-backend.dev/docs/email/deliverability">

A verified sending domain, leaving test mode, and the codes and invitations refused because they would not arrive.

</card>
</card-group>

## Not covered here

- **Sending from the browser.** The scaffolded `send` is an internal action: a public one that takes its recipient from the browser would relay mail from your verified domain to any address. To let people type an address, put the send behind a role, as `sendAsAdmin` does.
- **Audiences.** Segments replaced the provider's audiences, and the package wraps segments only.
- **Automatic retention.** Delivery records stay until you prune them: schedule `email.cleanup` and `email.cleanupAbandoned` from a cron.

<page-keys>

- Try it live in the playground: [/playground/platform/email](https://nuxt-backend.dev/playground/platform/email)
- API reference: [/docs/reference/api/email](https://nuxt-backend.dev/docs/reference/api/email)
- Source: [https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/email.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/email.ts)

</page-keys>


## Sitemap

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