2026-06-06 06:37:41 -06:00
|
|
|
# Contact Form Deployment
|
|
|
|
|
|
|
|
|
|
The website form posts to `/api/contact`. The handler is a small FastAPI app in
|
2026-06-09 11:57:54 -06:00
|
|
|
`api/contact_app.py` and sends mail through Postmark SMTP.
|
2026-06-06 06:37:41 -06:00
|
|
|
|
|
|
|
|
## VM Packages
|
|
|
|
|
|
|
|
|
|
Install Python and the contact API dependencies inside the container or Python
|
|
|
|
|
runtime that will serve the API:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
python3 -m pip install -r requirements-contact-api.txt
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The runtime needs these environment variables. Do not commit their values:
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-06-09 11:57:54 -06:00
|
|
|
SMTP_HOST=smtp.postmarkapp.com
|
2026-06-06 06:37:41 -06:00
|
|
|
SMTP_PORT=587
|
2026-06-09 11:57:54 -06:00
|
|
|
SMTP_USER=<postmark-server-token-or-smtp-user>
|
|
|
|
|
SMTP_PASSWORD=<postmark-server-token-or-smtp-password>
|
2026-06-06 06:37:41 -06:00
|
|
|
CONTACT_TO_EMAIL=<where messages should go>
|
2026-06-09 11:57:54 -06:00
|
|
|
CONTACT_FROM_EMAIL=<verified Postmark sender address>
|
|
|
|
|
RECAPTCHA_SECRET_KEY=<google-recaptcha-secret-key>
|
2026-06-06 06:37:41 -06:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Run Command
|
|
|
|
|
|
|
|
|
|
Run the API on an internal port, then route `/api/contact` to it from the
|
|
|
|
|
existing container/Caddy setup:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
uvicorn api.contact_app:app --host 0.0.0.0 --port 8091
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Health check:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
curl http://localhost:8091/api/contact/healthz
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The public static site can continue to be served as it is now. The only
|
|
|
|
|
deployment requirement is that requests for `/api/contact` and
|
|
|
|
|
`/api/contact/healthz` reach the FastAPI process.
|