
# Email Templates

Authentication emails are the part of your product a user reads before they have ever seen your app. `auth.emailTemplates` replaces the defaults with your own subject and body.

Every template is optional — Better Auth supplies a sensible default for each, so an app that sets none still sends working mail.

```yaml
auth:
  strategies:
    - type: emailAndPassword
    - type: magicLink
  emailTemplates:
    verification:
      subject: Verify your email for MyApp
      text: 'Hi $name, confirm your email: $url'
    resetPassword:
      subject: Reset your password
      text: 'Reset your password: $url'
      html: '<p>Click <a href="$url">here</a> to reset your password.</p>'
    magicLink:
      subject: Your sign-in link
      text: 'Sign in to MyApp: $url'
```

## The Eight Templates

| Template               | When it is sent                                       |
| ---------------------- | ----------------------------------------------------- |
| `verification`         | Email verification after sign-up.                     |
| `resetPassword`        | Password-reset request.                               |
| `magicLink`            | Magic-link sign-in.                                   |
| `emailOtp`             | Email one-time code (its presence enables email-OTP). |
| `twoFactorBackupCodes` | Two-factor backup codes delivery.                     |
| `welcome`              | Welcome email after verification.                     |
| `accountDeletion`      | Account-deletion confirmation.                        |
| `invitation`           | Admin-issued invitation (passwordless onboarding).    |

:::callout
**`emailOtp` is not just cosmetic.** Defining it _enables_ the email-OTP sign-in flow — there is no strategy entry for OTP. Every other template only changes the wording of a flow you already turned on. See [Magic Link & Email OTP](/en/docs/auth-passwordless).
:::

## Template Shape

Each template takes a required `subject` and an optional `text` and/or `html` body.

| Key       | Description                                       |
| --------- | ------------------------------------------------- |
| `subject` | **Required.** Subject line. Supports `$variable`. |
| `text`    | Plain-text body. Supports `$variable`.            |
| `html`    | HTML body. Supports `$variable`.                  |

Supplying both `text` and `html` gives clients a choice; supplying only `text` is the safest default, since it renders everywhere and never trips a spam filter on markup.

## Variables

Bodies and subjects support `$variable` substitution. Which variables carry a value depends on the email being sent — `$code` is meaningless in a password reset, `$inviterName` only in an admin invitation.

| Variable            | Meaning                                                             |
| ------------------- | ------------------------------------------------------------------- |
| `$url`              | Action link (verify, reset, magic link, invitation accept).         |
| `$name`             | Recipient's name.                                                   |
| `$email`            | Recipient's email address.                                          |
| `$code`             | One-time code (email-OTP).                                          |
| `$organizationName` | Organization name (invitations).                                    |
| `$inviterName`      | Name of the admin who sent the invitation (admin invitations only). |

```yaml
auth:
  emailTemplates:
    invitation:
      subject: '$inviterName invited you to MyApp'
      text: |
        Hi $name,
        $inviterName invited you to join.
        Set your password: $url
```

:::callout
**Templates do not deliver mail; SMTP does.** Magic link, email-OTP, password reset, verification and invitation emails all require SMTP. With SMTP unset the app boots with email disabled and logs a warning — the templates are read, and nothing is sent. See [Environment Variables](/en/docs/env-vars).
:::

## Related Pages

- [Strategies Overview](/en/docs/auth-strategies) — the `auth` block these sit in.
- [Magic Link & Email OTP](/en/docs/auth-passwordless) — the flow `emailOtp` enables.
- [Email & Password](/en/docs/auth-email-password) — where `verification` and `resetPassword` fire.
- [Invitations](/en/docs/auth-invitations) — where `invitation` fires.
- [Two-Factor](/en/docs/auth-two-factor) — where `twoFactorBackupCodes` fires.
