# Confirmation emails

Attach an email template to an endpoint under [/app/endpoints](https://forms.devxgroup.io/app/endpoints). When a submission comes in with an `email` field, form-relay renders the template and sends it via Resend.

## Mustache syntax

Use `{{var}}` to insert a variable from the submission payload. Add a fallback with `{{var|fallback}}`.

```html
<!-- Template body (HTML) -->
<p>Hey {{name|there}},</p>
<p>Thanks for joining. Tap the link below to confirm your email.</p>
<p><a href="{{confirm_url}}">Confirm subscription</a></p>
<p>
  Sent to {{email}} — reply to this email if you have questions.
</p>
```

## Double opt-in flow

Turn on "Require double opt-in" on the endpoint. On submission, form-relay generates a unique token and injects `{{confirm_url}}` into the template automatically. When the recipient opens that URL and presses Confirm, the lead is marked confirmed. Opening the link alone never confirms, so mail scanners cannot opt people in, and links expire 7 days after the submission. You can filter your leads list to confirmed-only when setting up broadcasts.

## Authoring email HTML offline

The template editor accepts raw HTML. To author with React Email components, install `@react-email/components` in a scratch project, write the email as a React component, then call `render(<YourEmail />)` to get the HTML string. Paste it into the template editor here. The Mustache `{{var}}` syntax works inside any string in your component, so you can write `{{name|there}}` directly in your JSX before calling `render()`.
