Let apps send email through the owner's own mail provider (#26)

This commit is contained in:
michael authored and GitHub committed 2026-11-22 18:07:41 -05:00
1 parent c7036c04d5
commit 7b6851c023
146 files changed
+737 -179

No files matched your search

+31 -1
View File
@@ -33,6 +33,36 @@ Cottage how to run it:
| `volumes` | named volumes to hand to a non-root user: `data: { uid: 1000, gid: 1000, mode: "0750" }` |
| `parameters` | settings people can see or change; secrets are generated (`generate: random32`, `random16` or `hex32`) |
Each parameter has a `key`, `label` and `type` (`string`, `int`, `bool` or `choice` with `choices`), and
may set `default`, `secret`, `generate`, `editable` (the owner can change it later), `group` (fields
with the same group are shown together) and `hint` (one line of help shown with the field).
`schema/cottage.schema.json` describes them under `$defs/parameter`. For a `choice` parameter, Cottage
also sets `<KEY>_IS_<CHOICE>=true` for the selected value, so a recipe can turn one choice into the
app's own words: `${SMTP_SECURITY_IS_TLS:+ssl}${SMTP_SECURITY_IS_STARTTLS:+tls}`. For every empty
parameter it sets `<KEY>_IS_EMPTY=true`, so `${SMTP_HOST_IS_EMPTY:+log}${SMTP_HOST:+smtp}` gives `log`
while no SMTP server is set and `smtp` once one is.
### Outgoing mail
Apps send mail through the owner's own mail provider (for example their email host, or a sending
service such as Postmark or Amazon SES). Cottage opens the submission ports 465, 587 and 2525; port
25 stays blocked, so apps can't deliver mail directly. If the app is configured by environment
variables, offer these fields, in this order, and map them onto the app's own settings:
```yaml
- { key: SMTP_HOST, label: SMTP server, type: string, editable: true, group: email, hint: "Your mail provider's SMTP server, e.g. smtp.fastmail.com. Leave empty to turn mail off." }
- { key: SMTP_PORT, label: SMTP port, type: int, default: "587", editable: true, group: email, hint: "587 for STARTTLS, 465 for TLS." }
- { key: SMTP_USER, label: SMTP username, type: string, editable: true, group: email }
- { key: SMTP_PASSWORD, label: SMTP password, type: string, secret: true, editable: true, group: email }
- { key: SMTP_FROM, label: Send as, type: string, editable: true, group: email, hint: "The From address, e.g. [email protected]. Your provider must allow it." }
- { key: SMTP_SECURITY, label: Connection security, type: choice, choices: [starttls, tls, none], default: starttls, editable: true, group: email }
```
Leave out a field only if the app has no such setting (Roundcube, for example, signs in to SMTP with
the mailbox login). With `SMTP_HOST` empty the app must start and work with mail off, so test the
recipe both ways. Apps that keep their mail settings in their own admin pages need no fields: say
in the README where to find them. CI checks these fields' shape.
Cottage provides `${HARBOR_PUBLIC_URL}` (the app's https:// address), `${HARBOR_HOSTNAME}`,
`${HARBOR_SLUG}` and `${HARBOR_POD_ID}`, and every parameter as a variable of the same name.
@@ -47,7 +77,7 @@ Rules (CI checks them):
create its admin on first visit, set `first_visit_claims_admin: true` in `cottage.yml`: Cottage
then keeps the app private to its owner until they've finished setup. Its `health_path` must
be a plain path other than `/`, because that path stays reachable while the app is private.
- Outgoing mail ports (25, 465, 587) are blocked. Don't rely on SMTP.
- Outgoing mail goes through the owner's own provider (see Outgoing mail); port 25 is blocked.
- A published version is never edited, not even a comment. Change anything in a recipe and bump
the `-c` revision.
- Copy follows the Cottage voice: plain, warm, specific, sentence case, no exclamation marks.