# Email Agent — Configuration and Environment

## Secrets

All secrets live in `~/.config/environment.d/10-secrets.conf` on `.13` (mode
600). The file is never committed. `docker-compose.yml` passes the names through
from the host environment.

| Key | Purpose |
| :--- | :--- |
| `GMAIL_USER` | Gmail account that receives the forwarded mail. |
| `GMAIL_APP_PASSWORD` | Gmail app password for IMAP and SMTP. No OAuth. |
| `EMAIL_AGENT_SESSION_SECRET` | Session cookie signing key. |
| `EMAIL_AGENT_PASSWORD` | Login password for Sam. |
| `JEV_API_KEY` | JEV (TypeSafe System One) API key. |
| `OMNIROUTE_API_KEY` | OmniRoute API key for reply drafts. |
| `HUB_TOKEN` | Shared bearer token for the Hub API. |
| `APPRISE_URLS` | Apprise destination for the summary email. |
| `EMAIL_AGENT_SUMMARY_TO` | Summary recipient. |

`environment.d` reaches the systemd user manager. It does not reach a fresh SSH
shell. Read the values explicitly, or pass them to `docker compose`.

## Runtime variables

| Variable | Default | Meaning |
| :--- | :--- | :--- |
| `EMAIL_AGENT_ENV` | `development` | `development`, `production`, or `test`. |
| `EMAIL_AGENT_ADDR` | `:8790` | Listen address. |
| `EMAIL_AGENT_PORT` | `8790` | Listen port when `ADDR` is unset. |
| `EMAIL_AGENT_DB_PATH` | `data/email_agent.db` | SQLite file. Container uses `/data/email_agent.db`. |
| `EMAIL_AGENT_LOG_LEVEL` | `info` | `debug`, `info`, `warn`, `error`. |
| `EMAIL_AGENT_PUBLIC_BASE_URL` | — | Public URL for links. |

## Gmail variables

| Variable | Default | Meaning |
| :--- | :--- | :--- |
| `EMAIL_AGENT_IMAP_HOST` | `imap.gmail.com` | IMAP host. |
| `EMAIL_AGENT_IMAP_PORT` | `993` | IMAP port. Implicit TLS. |
| `EMAIL_AGENT_IMAP_LOOKBACK_DAYS` | `14` | First-scan window. |
| `EMAIL_AGENT_IMAP_MAX_MESSAGES` | `100` | Per-scan message cap. |
| `EMAIL_AGENT_SMTP_HOST` | `smtp.gmail.com` | SMTP submission host. |
| `EMAIL_AGENT_SMTP_PORT` | `587` | SMTP port. STARTTLS. |

The dialer uses `tcp4`. Gmail is reached over IPv4 only.

## Model and integration variables

| Variable | Default | Meaning |
| :--- | :--- | :--- |
| `JEV_BASE_URL` | `https://api.typesafe.ai` | JEV base URL. |
| `JEV_MODEL` | `jev-latest` | System One model alias. |
| `EMAIL_AGENT_CLASSIFY_CONCURRENCY` | `4` | In-flight JEV requests. |
| `EMAIL_AGENT_CLASSIFY_MAX_MESSAGES` | `200` | Messages per classify run. |
| `OMNIROUTE_BASE_URL` | `http://192.168.20.13:20129/v1` | OmniRoute gateway. |
| `OMNIROUTE_MODEL` | `auto/best-chat` | Reply-draft model. |
| `HUB_BASE_URL` | `http://192.168.20.13:8788` | Hub base URL. |
| `HUB_NOTIFY_TIMEOUT` | `5s` | Notify call timeout. |
| `APPRISE_URL` | `http://192.168.20.35:8210` | Apprise API base. |
| `APPRISE_KEY` | — | Stored Apprise configuration key. |
| `EMAIL_AGENT_SUMMARY_TO` | `samuelrolfe@gmail.com` | Summary recipient. |
| `EMAIL_AGENT_RETENTION_DAYS` | `30` | Message-body window for `-retain` (AGENTS.md section 7). |
| `EMAIL_AGENT_ACTIONS_LOG_MAX_ROWS` | `50000` | Cap for the append-only `actions_log`. |

## Config paths

| Path | Role |
| :--- | :--- |
| `/home/sam/paseo/projects/email_agent/` | Project source and docs. |
| `/home/sam/paseo/projects/email_agent/docker-compose.yml` | Own container and image. |
| `/home/sam/paseo/projects/email_agent/.env.example` | Full list of variable names. |
| `/data/email_agent.db` | SQLite file in the container. |
| `email_agent_data` | Docker named volume for the database. |

## Ports

| Port | Host | Service |
| :--- | :--- | :--- |
| `8790` | `.13` | Email Agent HTTP. |
| `443` | `.35` | Caddy TLS for `mail.lab.audasmedia.com.au`. |
| `993` | cloud | Gmail IMAP to Gmail. |
| `587` | cloud | Gmail SMTP to Gmail. |
| `8788` | `.13` | Central AI Hub. This service both serves and calls it. |
| `8210` | `.35` | Apprise API. |
| `20129` | `.13` | OmniRoute gateway. |
