# Email Alert Setup

This page shows how to configure SMTP inside the TUI with `smtp` commands, manage recipients, and send a test email.

## Setup Steps (Gmail, 587 STARTTLS)

```bash
smtp host smtp.gmail.com
smtp port 587
smtp username your@gmail.com
smtp password abcdefghijklmnop
smtp from your@gmail.com
smtp add ops@example.com
smtp add oncall@example.com
smtp enabled true
test
```

Each command writes to `.webMonitor.json` immediately; no restart is needed.

## Input Rules

| Rule | Description |
|------|-------------|
| Whitespace-separated | Commands split with `strings.Fields`, and each value takes only the first token |
| Values cannot contain spaces | Gmail shows app passwords as four groups of four characters; remove the spaces when entering them |
| `port` must be an integer | Non-integer values are rejected |
| `enabled` | `true` or `1` enables; any other value disables |
| Recipient dedup | `smtp add` ignores an address that already exists |

## View the Settings

Type `smtp` (or `smtp show`) to switch to the SMTP view, where the System panel shows the current settings:

| Field | Display |
|-------|---------|
| Host / Username / From | `unset` when empty |
| Password | Masked with the same number of `*` |
| To | All recipients joined with commas |
| CC | `unset` when empty |
| Enabled | Green `Enable` / red `Disable` |

Type `back` or press <kbd>Esc</kbd> to return to the main view.

## Test Email

`test` sends an HTML email titled `Website Monitoring System - Test` in the background. Send errors go only to stderr and never appear in the System panel, so check the inbox to confirm delivery.

## CC

The TUI has no command for CC. When you need it, edit `config.cc` (a single string) in `.webMonitor.json` **after** the program exits. When it is empty, the Cc header carries the sender address.

## Disable Alerts

```bash
smtp enabled false
```

Once disabled, neither alerts nor `test` send email; the other settings are kept.

See [SMTP Connection](/smtp-connection) for how each port connects.
