ADR-0172 — A broadcast is sent in batches, once per recipient
Status: Accepted · Date: 2026-10-11 · Track: launch wave 2, api
workstream (launch roadmap #34) · Builds on: the suppression list and
one-click unsubscribe (launch wave 1)
Context
The admin's "send" sets a broadcast's status to processing. Nothing acted on
it. A broadcast_email job handler was registered but nothing enqueued it, and
it had four defects:
- it read the subject and content from
settings, while they are columns; - it sent to every active account, ignoring the stored target list and the newsletter opt-out;
- it kept no record of who had been sent what, so a retry would have mailed everybody again;
- it marked the broadcast sent after the first 500.
Decision
- Send is still the status. When a broadcast becomes
processing(on create, or by an update from draft), the handler callsBroadcastSender.Start, which enqueues onebroadcast_emailjob. If no sender is wired (no SMTP), the request is refused with 503 and the broadcast stays a draft. If the enqueue fails, it goes back to draft and answers 503. - One ledger row per recipient (
broadcast_deliveries, migration 000047). A batch claims up to 200 targets with a singleINSERT … ON CONFLICT DO NOTHING, and only then sends. A retried or duplicated batch finds its recipients already claimed, so a recipient gets a broadcast at most once. A failed send is recorded asfailedand not retried. That is the price of never sending twice. - Who may receive it: the targets snapshotted in
users_idsthat are still active, subscribed to the newsletter, and not suppressed by a hard bounce or complaint. Every other target is claimed asskipped. - Every copy can be unsubscribed from. A fresh token per recipient goes in the RFC 8058 List-Unsubscribe header and in a visible link appended to the body. With no token, the copy is not sent.
- A full batch enqueues the next one. A short batch marks the broadcast
sent. A broadcast that is no longerprocessingsends nothing more, andsent_emailscounts sent copies.
Consequences
- An admin cannot pause or cancel a send in progress. The API still refuses
edits to a
processingbroadcast, as before. - Links in the content are not rewritten to the signed
/broadcast/clickform, and no open pixel is added. Click and view counts stay at zero until the composer emits tracked links. - The admin UI must show the 503 message.
Source: docs/decisions/0172-a-broadcast-is-sent-in-batches-once-per-recipient.md