caelum0x e91eb482bb feat(send): verify recipient addresses with reacherhq before every send
Wires reacherhq/check-if-email-exists (self-hosted, MIT licensed) as a
pre-send validator in the queue worker, right before the provider dispatch
that every send path (API, SMTP proxy, campaigns, scheduled, double opt-in)
shares. Recipients confirmed undeliverable are dropped before a send credit
is spent instead of bouncing after the fact.

Fails open by design: disabled, unconfigured, slow, or unreachable verifier
means every recipient is treated as unverified and the send proceeds
unchanged. A down validator must never silently drop a legitimate send.

- apps/web/src/server/service/address-verification-service.ts: REST client
  for the reacherhq/backend HTTP API (POST /v0/check_email), batched,
  timeout-bounded, never throws.
- apps/web/src/server/service/email-queue-service.ts: call the verifier
  right before provider.sendRawEmail; reject with status REJECTED when
  every recipient is invalid, otherwise send to the deliverable subset only.
- apps/web/src/env.js: REACHER_ENABLED / REACHER_API_URL / REACHER_API_KEY /
  REACHER_TIMEOUT_MS / REACHER_BLOCK_VERDICTS.
- compose.yml: optional `reacher` sidecar behind a profile (needs outbound
  port 25, so it's opt-in, not part of the default self-host stack).
- docs/SELF-HOSTING.md, .env.example, .env.selfhost.example: how to turn it
  on.

25 new/updated unit tests (12 for the service in isolation covering block,
allow, fail-open on error/timeout/non-2xx, disabled, unconfigured, batching,
custom block list; 13 in the queue worker covering full-block, partial-block,
and the default pass-through path). Full web unit suite: 574/574 passing.
2026-10-16 17:50:06 +03:00
..