Skip to content
Toolkit

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 calls BroadcastSender.Start, which enqueues one broadcast_email job. 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 single INSERT … 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 as failed and not retried. That is the price of never sending twice.
  • Who may receive it: the targets snapshotted in users_ids that are still active, subscribed to the newsletter, and not suppressed by a hard bounce or complaint. Every other target is claimed as skipped.
  • 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 longer processing sends nothing more, and sent_emails counts sent copies.

Consequences

  • An admin cannot pause or cancel a send in progress. The API still refuses edits to a processing broadcast, as before.
  • Links in the content are not rewritten to the signed /broadcast/click form, 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

Library