# Site form

External component: a form that sends mail or posts to Account Engagement. Everything is configured in the `data` field (an Object field). The set of form fields, the copy and the delivery all live there.

## Fields & Schema

| Field | Type | Required | Notes |
|-------|------|----------|-------|
| `externalComponentType` | Symbol | Yes | Must be `"Site form"` |
| `data.intent` | string | Yes | `newsletter` posts to Account Engagement and draws the split band (copy left, fields right). `invest` sends mail through Resend and uses that same split band with an h2. `contact` sends mail through Resend and draws the contact band. If the entry before it is Contact info, the contact form draws nothing, because Contact info already draws the band. |
| `data.recipient` | string | Yes on every intent except `newsletter` (`contact`, `invest`) | The address production mail goes to. See **Recipient** below. |
| `data.intro` | string | No | Intro line |
| `data.fields` | array | Yes | Each item: `name`, `label`, optional `required` (boolean), `format` (`email`), `autoComplete` |
| `data.submitLabel` | string | No | Button text. Defaults to "Submit". |
| `data.requiredMessage` | string | No | Shown under a required field left empty |
| `data.emailMessage` | string | No | Shown under an invalid email |
| `data.thanks` | string | No | Shown after a successful send. Defaults to "Thank you." |
| `data.error` | string | No | Shown when the send fails. Defaults to "Something went wrong". |
| `data.address`, `data.phone`, `data.email` | array / object | No | Contact page only (a Contact info component placed before the form draws the form band itself). Address lines, and `{ "label", "href" }` for phone and email. |

## Recipient

`data.recipient` decides where live mail goes. Read these rules before editing it.

- **Production reads the PUBLISHED entry.** Saving a draft changes nothing on the live site. The new address takes effect only when a person publishes the entry. cms-edit saves drafts and does not publish.
- **No fallback.** If `recipient` is missing, empty, or not a valid email address, production does not send. The visitor sees the `data.error` message and the site logs `[site-form] failed reason=not_configured_recipient` (or `not_configured_resend_key` when the Resend key is also missing). Check it is set on **both** the contact and the invest Site form entries before a production release.
- **Other environments ignore it.** Local, development and preview send nothing unless `ALLOW_OUTBOUND_FORMS=true`; the visitor still sees the thanks message. When it is on, mail goes to the `RESEND_TO` environment variable, never to `data.recipient`, so a test submit cannot reach the live inbox. The preview site reads drafts, but it still does not use this field.
- **The `newsletter` intent has no recipient.** It posts to Account Engagement.
- Use one plain address, for example `info@example.com`. No display name, no list of addresses.
- Never put the address in a heading, intro or any visible copy field.

## Usage

```bash
cms-edit set @ref data --json '{"intent":"contact","recipient":"info@example.com","fields":[{"name":"firstName","label":"First Name","required":true},{"name":"email","label":"E-mail address","required":true,"format":"email"}]}'
cms-edit save
```

`set data --json` replaces the whole object. Read the current `data` first and change only the key you mean to.

After a recipient change, ask the person who publishes to publish the entry, then submit the live form once and confirm the mail arrives.
