Skip to content

Emails 0.3.0: Delivery events from several Amazon SES accounts

Emails 0.3.0 lets the PhoenixKit email module collect delivery events from more than one Amazon SES account. Each account gets its own queue and credentials, and the email log now records which account sent a message.

One queue per SES account

Event collection through SQS could only reach one AWS account. With two SES connections, one account’s bounces, deliveries and complaints were never read, and the poller could even be given one account’s queue with the other’s keys.

Now each Amazon SES account has its own row under Per-account event tracking, with its own queue, dead letter queue, topic, configuration set, region and credentials. Add account adds an SES connection from Integrations, and each row has its own Setup Infrastructure button that creates the resources in that account. Unchecking an account leaves its events unread until it is checked again. A site still on the single global queue is told so, with the queue’s name and how to give each account its own.

SES only publishes events through a configuration set in the account that sent the message, so the configuration set name now belongs to each account. When the sending account cannot be told for sure, the global name is still used, because a configuration set that does not exist in the sending account makes the send fail.

Tracking settings, reorganised

The Email Sending settings no longer have a separate “Amazon SES & SQS” section. Each row in the delivery event tracking table now opens to its own settings, and the SES row holds what that section did: credentials, the per-account queues, Setup Infrastructure, Add account and the warnings. The polling interval and the SQS tuning settings moved into the opened row too, and the “Performance Tips” block is gone. The read-only “Inherited settings (legacy)” list is gone from the page; sites that have not moved to per-account tracking still use those settings.

Fixed along the way: three Estonian and Russian texts showed another setting’s wording; enabling polling is now one step that either fully succeeds or changes nothing; and the settings forms, which used styles missing from daisyUI 5, are styled again.

Upgrading

Run the migration before you restart: mix phoenix_kit.update --yes, then restart. It adds an integration_uuid column to the email log, and every query on the log fails until it exists. Run mix phoenix_kit.doctor first: this migration starts the module’s own migration chain by taking over its six tables, and doctor reports the two problems that could get in the way. The migration gives up after five seconds of waiting for a lock instead of hanging the deploy, so retry in a quiet moment if it does. It also briefly locks the email log for writes while it builds an index.

For a send through a non-default connection of the same provider, the recorded account is a best guess and can name the default account.

Full release notes: Emails 0.3.0

0.3.0 · 13 August 2026

Upgrading — read this first

This release adds a column to phoenix_kit_email_logs, and the schema in the code expects it. Migrate before you restart, not after:

mix phoenix_kit.update --yes   # applies the module chain (Emails V01)
# ...then restart the application

Restarting first leaves the running code selecting a column the database does not have, and every query against phoenix_kit_email_logs fails until the update lands. Both steps are idempotent, so a host that has already run them is unaffected.

Run mix phoenix_kit.doctor first. V01 adopts the module’s six tables, which means it is the first thing to replay their constraints on a long-lived database, and doctor reports the two conditions that make that interesting: a drifted phoenix_kit_email_events shape and orphaned email_log_uuid rows.

The migration bounds itself with SET LOCAL lock_timeout = '5s', so behind a long-running reader it fails fast with a clear error instead of hanging the deploy — retry during a quiet window. It also takes a brief write lock on phoenix_kit_email_logs while building the new index; see PhoenixKit.Modules.Emails.Migrations’ “Locking” section if that table is large.

Added

  • Multi-account AWS SES delivery event tracking. SQS polling could only ever reach one AWS account: the queue URL was a single setting, the credentials cache had a single key, and the Oban chain is unique per worker. With two SES connections configured, one account’s events were never collected — and the poller could be handed account A’s queue with account B’s keys.

    One Oban chain still, with N accounts polled inside each cycle (the shape BrevoPollingJob already used). Each account carries its own queue, DLQ, topic, configuration set and region under an aws_tracking:<integration_uuid> setting, its own credentials, and its own opt-out. The “Amazon SES & SQS” settings section grows a row per account, each with its own “Setup Infrastructure” button that creates the resources in that account.

  • Per-account SES configuration sets. SES publishes delivery, bounce and complaint events only through a configuration set that exists in the SENDING account, so a single global name is silence for every account but one. The name now travels with the account. While the sending account can only be inferred (see below), the global name is still used for safety: a configuration set that does not exist in the sending account is a failed send, not just a lost event.

  • phoenix_kit_email_logs.integration_uuid — which account sent a message, not just which provider kind. Nullable, best-effort, and backed by the SES event’s own mail.sendingAccountId, which is now kept in the stored event_data alongside sourceArn and configurationSet as verifiable provenance.

  • A module-owned migration chain (PhoenixKit.Modules.Emails.Migrations). V01 adopts the six tables nothing outside this package uses, alongside core’s baseline, which still creates them — a deliberate transitional duplication. See dev_docs/reports/2026-08-12-emails-table-adoption.md.

Changed

  • The Email Sending settings page no longer has an “Amazon SES & SQS” section. It was listed as a peer of “Delivery Event Tracking” while actually being the detail of one of that table’s rows: it repeated the table’s “is collection on” answer, and nothing on the page said which row it belonged to. Every tracker row now expands to its own settings, and the SES row expands to exactly what that section used to hold — credentials source, per-account queues, Setup Infrastructure, Add account, the warnings. Nothing was removed; it moved one level in.

    Trackers name their own settings component through a new optional EventTracker.settings_component/0 callback, so a provider that has none (Brevo today) renders a note instead, and a future Mailgun needs no panel code either way.

  • The polling interval moved out of the tracker table into the expanded row, next to the SQS worker tuning knobs (max messages per poll, visibility timeout) that moved there with it. A value set once and then never looked at no longer holds a permanent column. The “Performance Tips” block is gone.

  • The global aws_* pipeline settings are no longer shown or editable. The read-only “Inherited settings (legacy)” accordion listed the SAME fields the per-account rows carry (two of which — SNS topic ARN, queue ARN — are read by nothing at all), inviting operators to reason about values only the account rows can change. The code fallback is untouched: the poller and the tracking interceptor still read aws_sqs_queue_url, aws_region and friends for an install that has not moved to per-account tracking. Only the UI is gone — the warning that sending is still running on legacy credentials stays.

Fixed

  • The “Add account” button in the SES settings rendered as “Accounts” in every locale — mix gettext.extract --merge had fuzzy-matched it to the table column of that name, and no test rendered the button.

Fixed (review follow-ups, #33)

  • Three translations were glued to the wrong source string. They had been merged onto a similar-looking msgid and left fuzzy, which gettext ignores, so the UI showed another setting’s wording or fell back to English. The worst told the operator that a failed send-queue update was about saving email headers. The catalogues now extract with zero fuzzy entries.

  • Enabling polling is one transaction, not three steps. It used to write the eligibility flag, then the polling flag, then insert the first job — a failure in step two or three left the flag flipped with polling off, and the panel reported the failure without saying what it had already changed. The deliberate asymmetry with disabling (which leaves the eligibility flag on, because that same flag gates the SNS webhook path, which polls nothing) is now argued in the EventTracker docs instead of contradicting them.

  • An install on the global queue no longer looks unconfigured. Removing the legacy accordion removed the only place that queue was ever shown, so such an install was told “no accounts configured” while the poller was reading it and the tracker said Active. The panel now names the queue and says how to give each account its own.

  • The settings forms are styled at all now. form-control, label-text and label-text-alt do not exist in daisyUI 5 — not merely outdated, they styled nothing: field labels fell through to the one live .label rule, which dims text to 60%, and hints rendered at body size. Both files now use fieldset/fieldset-legend, the idiom core’s own forms use.

  • The status line that repeated its own row is gone. It read should_poll?/0, which is exactly what the State column above it already splits into “Off” and “Idle — no integration”, each with a tooltip naming what to fix.

  • The scrubber’s linearity test no longer measures wall clock. It timed a large run that gets preempted more often than a small one, so a busy machine looked like quadratic scrubbing. It counts reductions now — charged for work actually done, stable to ~0.1% across runs, blind to load. The ceiling is unchanged and a quadratic implementation still costs ~16x.

Changed

  • Dependency updates: phoenix_kit 2.3.0.

Known limitation

Core does not yet pass the sending integration’s uuid to the tracking interceptor, so for a send routed explicitly through a non-default connection of the same provider kind, integration_uuid is inferred and can name the default account instead. The column is an index, not a source of truth; the SES event’s mail.sendingAccountId is. Per-account configuration sets are deliberately withheld in exactly that ambiguous case.


Emails 0.3.0. Install or update: {:phoenix_kit_emails, "~> 0.3"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.