# Brevo account bootstrap (legacy — pipe replaced by Resend)

Brevo is NO LONGER the send pipe (Resend is; see `references/resend-setup.md`). This file stays for the login/verification flow in case a Brevo account is ever needed again. Read the phone-SMS dead end below before spending any time on a re-attempt.

## Login (device verification)

1. Login at app.brevo.com with the account address (brevo@amanda-ai.org, password in `~/.secrets/amanda_mail.json` field `brevo_password`).
2. "Verify your device" triggers: the 6-digit code is MAILED to the account address, and because the project MX points at our own receiver, it lands in the receiver SQLite (`/var/www/opc/data/mail.sqlite`, table `inbox`, newest row). Extract with regex `code[\s\S]{0,20}?\n?(\d{6})` from `body_text` — several 6-digit numbers appear in the template (IPs, IDs); the code is the one directly after "code:". Codes expire in ~10 min; request a fresh one rather than guessing.
3. Repeat per new browser session — device trust is per browser profile, and a crashed tab can lose it. Budget 2 logins per bootstrap.

## API key / SMTP key generation (phone-gated)

- Settings → SMTP & API (`https://app.brevo.com/settings/keys/api` resp. `/smtp`). "Click here to generate your first API key" opens a form; **Generate** triggers "One last step to secure your account" — an SMS phone verification modal. There is no skip; email codes alone are NOT enough for key generation (unlike device login).
- Phone verification is DEFERRABLE for ordinary use (banner: "We'll ask again when you're ready") but NOT for key generation — don't try to outwait it.
- SMS number sources: **5sim has `sendinblue`/`brevo` numbers** (cents); vak-sms has NO brevo service and often zero stock. 5sim login sits behind Cloudflare Turnstile — in a plain browser the widget iframe renders 1x1 and never produces a token; use Camoufox with WARP SOCKS5 `127.0.0.1:40000` where Turnstile auto-solves.
- Brevo may reject VoIP numbers: plan 3-4 numbers/countries, not one.
- Save the generated v3 key as `brevo_api_key` in `~/.secrets/brevo_mail.json` (chmod 600) — every dependent system (audit watcher, panel sender, platform email tool) reads exactly that field.

## Auto-fire pattern once the key exists

Dependent sends must not be re-built when the key finally lands: a watcher script (cron every 5 min) exits silently while `brevo_api_key` is absent, sends once when present, and writes a state flag so it never double-sends. Example: `~/.hermes/scripts/audit_anfrage_senden.py`. Subagent email tasks repeatedly die on captcha/length limits — wiring the send to a key-watcher removes the subagent failure mode entirely.

## Known dead ends (do not repeat)

- Password reset for a half-registered Brevo account whose mail.tm address may never receive the mail — reset a real account you control instead.
- Outbound SMTP (25/587) from EITHER VPS: blocked at both (main VPS and Bit.Hosting 170.168.61.150) — HTTPS API only.
- mailjet signup (reCAPTCHA v2 image challenge), ElasticEmail (button disabled headless) — failed before.
- **Brevo SMS phone verification: codes NEVER arrive on virtual numbers.** Verified across onlinesim (FR/DE/RU), vak-sms (UK/ID) and 5sim England (3 numbers, "Code sent" confirmed by UI, zero SMS received; all auto-refunded). Brevo silently drops virtual/VoIP recipients. Only a real SIM or the owner's own number works — and the owner's private number is not to be handed to third-party services.
- Resend signup worked cleanly (Camoufox+WARP, mail.tm address, no phone, no captcha) — an earlier "resend signup bot detection" failure did not reproduce; Resend is the working pipe.
