Emails 0.1.19: Outgoing email goes through an Oban send queue
Emails 0.1.19 can send outgoing email through an Oban queue with up to five attempts, instead of during the web request, and adds a System status card that shows what the module is really doing.
When the host app has an emails Oban queue, eligible messages are queued, including mail the app sends through its own mailer. Authentication mail and messages with attachments are still sent at once, and anything the queue cannot take falls back to an immediate send. Two switches in the Email Tracking settings control this: Queue Outgoing Emails, on by default, and Queue Authentication Emails Too, off by default. Test sends are never queued.
The status card shows what is logged and why not, which mailer or integration mail leaves through, the queue’s state and today’s counts. It warns when the sender address would make every log entry fail.
Upgrading
Needs PhoenixKit 1.7.217 or later. If your app has an emails Oban queue, eligible mail starts going through it after the update; turn Queue Outgoing Emails off to keep sending inline. Queued messages stay in Oban’s job table until pruned, so configure Oban.Plugins.Pruner.
Full release notes: Emails 0.1.19
0.1.19 · 29 July 2026
Added
- Outgoing send queue.
Queueimplements core’s optionalc:PhoenixKit.Email.Provider.maybe_enqueue/2callback (floor raised tophoenix_kit ~> 1.7.217), so every outgoing message — including mail the host app sends through its own statically configured mailer — is offered to the:emailsOban queue and delivered bySendJob(max_attempts: 5) instead of on the request. Every decline is “send it inline now”, never an error: a disabled system,email_queue_enabledoff, no:emailsqueue in the host’s Oban config (a package cannot add one, andOban.insert/1would happily store a job nobody drains), a per-messagequeue: false, authentication mail, attachments, anOban.insert/1error, and even a raise or a DBConnection exit all fall through to an inline send. Delivery is at-least-once, which is why authentication mail is excluded by default. (#22) - System-status card in Settings → Email Sending → Email Tracking. Reports what the module is doing, not what it is configured to do: whether anything is being logged and why not (a
fromaddress that fails theLogschema’s own format rule makes every insert fail, and the interceptor swallows that by design), which mailer or integration messages actually leave through, the queue’s state and depth, and today’s logged/sent/failed/queued counts. (#22) - Two switches for the queue — “Queue Outgoing Emails” (
email_queue_enabled) and “Queue Authentication Emails Too” (email_queue_auth_mail) — in the same settings section as the card. Post-merge review: the queue shipped default-on and reported read-only, with no way to turn it off short of editing the settings table.
Changed
- Behavioural default for existing installs:
email_queue_enableddefaults to true, so a host that has (or later adds) anemails: NOban queue starts routing eligible outgoing mail through Oban after this upgrade. Authentication mail and messages with attachments are still sent inline. Hosts with no:emailsqueue are unaffected — nothing is queued and mail is sent as before. Interceptor.intercept_before_send/2leaves a message that already carriesX-PhoenixKit-Log-Idalone, so the queue worker’s re-send updates the existing log row rather than writing a second one and stranding the first at “queued”.Log.email_format_regex/0exposes the sender-format rule the changeset validates with, so the status card’s warning cannot drift from the validation that causes the failure.- Queued mail carries its recipients, subject and bodies in the Oban job’s args until the row is pruned — independent of
email_save_bodyandemail_retention_days, which only govern this module’s own tables. ConfigureOban.Plugins.Pruneraccordingly; documented onQueue.serialize/1. - Callers that route a send through an explicitly chosen integration (
Mailer.deliver_via_integration/3with a non-default uuid) must passqueue: false: core hands the queue only the integration’s:provider, never its uuid, so a queued re-send resolves the default transport. Documented inQueue’s moduledoc andAGENTS.mduntil core carries the uuid.
Fixed
- Test sends are never queued (
skip_queue: trueon the template-editor preview and bothProvidertest-email paths). A queued test would flash “sent successfully” the moment Oban accepted the job — before any relay had seen it, and while a later failure went unreported. (#22) - A raise inside a queued send (an adapter that throws instead of returning
{:error, _}, a pool timeout) never reaches core’s after-send hook, so the log row stayed at “queued”; after the fifth attempt Oban discarded the job and nothing ever closed the row out.SendJobnow marks the row failed on the last attempt and reraises, leaving Oban’s own recording, backoff and discard untouched. - The card’s “no
:emailsOban queue” warning no longer contradicts the Queue row it sits above when the whole email system is disabled (it is gated onQueue.status/0 == :no_oban_queue, the one state that means “on, and cannot run”). - A default send integration saved without a name rendered a blank “Sending through” value instead of the card’s own fallback label.
- Three dialyzer errors that made
mix precommitfail on the merged branch: an unreachablelog_uuid/1fallback clause inQueue, amap() === nilguard inSendJob, and anis_binary/1branch inStatusthat core’sget_from_email/0typing proves dead (rewritten to stay nil-safe at runtime).
Emails 0.1.19. Install or update: {:phoenix_kit_emails, "~> 0.1"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.