Transactional email (welcome POC)
Status: Landed on main in #754 (merged 2026-10-10 20:13 IDT, merge ac482083). Not enabled. No real email has been sent, and nothing in the PR turns the welcome email on or promotes it to production. Plan: docs/plans/transactional-emails-poc.md.
One template only: a code-owned welcome email for eligible new Studio sign-ups. No historical backfill and no endpoint that mails an arbitrary recipient.
Flow
Admin Maily welcome editor
draft → immutable publication → controlled exact-revision test
tested staging revision → imported as a destination draft only
eligible Studio onboarding → Effect sender → durable outbox
bounded preparation/claim → provider submission → accepted / failed / unknownAuthoring (admin)
- Constrained Maily (Tiptap) editor nested under admin. Drafts use optimistic versioning; publishing creates an immutable revision.
- Staff writes are proof-gated (recent sign-in, audit). Save, import, and publish never enable mail. Activation is a separate, explicit, DB-owned step.
- Staging → production: an exact-hash, tested staging revision can be imported, but only as a draft in the target env. Sender, Studio URL, and activation stay owned by the destination env.
Editor redesign (#772, merged 2026-10-11 10:26 IDT, merge 35625333)
- Layout:
/emailsis a catalog table (name, purpose and when it sends, status, preview)./emails/welcomehas a top bar (Save, Send test email, Publish, and a ⋯ menu for automatic sending, import/export, download/discard, refresh, send history), Subject and Preview text fields, the styling editor beside a live preview (desktop/mobile, HTML/text, sample name), and a Variables panel. - Styling contract: the validated document now allows Maily's native styling: links, text color, lists, quotes, dividers, spacers, sections, columns, images, logos, footer, and styled buttons (Studio URL variable or literal https). Attrs are bounded and URLs are https-only. Raw HTML, repeat, and conditionals stay excluded. The editor uses Maily extensions behind Brilliant's own toolbar, restricted to that allowlist.
- Buttons: right-click (or Enter/Shift+F10, or the touch "Edit button" chip) opens a menu for label, link, style, corners, alignment, size, colors, and delete.
- Send test email: sends to your staff address, from the draft (including unsaved edits) or the published revision, and reports accepted, failed, or uncertain (never resent).
- Base layout: every email (preview, test, real send) gets a code-owned Brilliant logo header (PNG, since Gmail and Outlook don't show SVG) and footer (Website, Privacy, Terms;
/securitydropped in #967 (merged) because the site 301s it home). Links and logo use the destination'sSITE_ORIGIN; never stored in the document. - Removed: reply-to (backend, config, the
Pulumi.staging.yamlline, env renderer). - Rollback caution: two-way only until the first styled save. Older code can't decode drafts or publications with new blocks and returns
incompatible_content(also for a prodstaging-importwhile prod runs older code). Format marker stays[email protected]. To roll back, first restore a draft without new blocks. Hold prod promotion until prod runs this code.
Email editor state machine (#929, merged)
#929 (merged 2026-10-15 10:54 IDT, merge 309b1b69) runs the admin welcome template editor as a parallel XState setup() machine (emailEditorMachine under apps/admin/web/src/features/emails/). Draft modes, tab backup, dialogs, and in-flight save/publish/enable/import/export live in the machine; TanStack Query still loads the template once; the Tiptap editor stays a ref. Behaviour (backup restore, 409 conflict, dirty vs clean refresh, save leaving dialogs open) is unchanged. Full ownership table and deferred items: Admin client state.
Sending (outbox)
- Written in Effect. Lifetime idempotency per recipient/template; bounded preparation and dispatch claims with backoff; a DB-clock submission lease with exact-token compare-and-set.
- Outcomes are
accepted,failed, orunknown.unknownis never blindly resent. - Personal payload is erased after use; dedupe tombstones are kept.
- Rendering is lazy (Maily initializes only inside render), so login/API startup is unaffected, and provider/render work never blocks login.
- Onboarding-marker storage failure still returns 503 (approved policy); log-and-continue would be a separate product decision.
Database
Migration 0041 (appended after 0040 app-launches; shipped migrations are append-only). Old owned side envs must be rebuilt, not ledger-rewritten.
Before it can go live
- Privacy repair for the staging sender domain: refreshed staging infra apply plus readback showing previews disabled (#753 / #749). See Hosting & infra: staging system-email domain.
- Rebuilt owned env, then authenticated editor, render, signup, controlled-inbox, and idempotency checks.
- Follow-ups: request-bound staff assertions (#757) and provenance-channel trust (#758).
Production sending and open recipients (#921, merged)
PR #921 (opened 2026-10-14 13:46 IDT by yoni-monday, branch email-prod-sending; merged 2026-10-14 14:40 IDT, merge b9407082, head e01d6200) declares production email sending and drops the single-inbox allowlist. Code and stack config are on main; production still needs an infra apply and a secrets push before welcome publish works.
- Production sender:
Pulumi.prod.yamlnow hasemail.sendingDomainmail.brilliant.ai(on thebrilliant.aizone), senderBrilliant <[email protected]>, andartifactSourceOrigin: https://app.brilliant.rocks, so production welcome publish reads tested staging artifacts and is no longer missing its sender. The admin email screen should stop showing "configuration unavailable" once the control plane is deployed with this config. - Staging: turns on the artifact exporter (
artifactSourceEnabled: true) and removesallowedRecipients: [[email protected]]. - Recipient rule (decision): an empty recipient list means any valid address, in every environment (including side envs). A non-empty list still means exact mailboxes only, and wildcard, domain or header-injection entries are still rejected. Before, production allowed everyone and every other environment had to name controlled recipients. The check is now whether
EMAIL_ALLOWED_RECIPIENTSis set, not the environment name (apps/control-plane/src/email/config.ts,repository.ts; Pulumiinfra/pulumi/src/email-config.ts). - Hard refuse: addresses at
@e2e.brilliant.rocksare always refused. That Auth0 fixture domain has no MX, so mail would hard-bounce; withdrop_suppressed_recipients: falsea bounce would repeat. - Shared secret:
EMAIL_TEMPLATE_EXPORT_KEYis one external secret with the same value on staging and production; it is not in the stack files. Workers pick it up on the next secrets push, and its absence blocks import. - Both sending domains are created with
previewEnabled: falseanddrop_suppressed_recipients: false.
Before any production send
Cloudflare's create API ignores the preview flag on the first call (same drift as staging). After the subdomain exists in state, repair with refresh-urn set to urn:pulumi:prod::brilliant-infra::brilliant:infra:Environment$brilliant:infra:Cloudflare$cloudflare:index/emailSendingSubdomain:EmailSendingSubdomain::brilliant-prod-cloudflare-email-sending (see single-resource refresh). The production apply must show the in-place previewEnabled: true → false update, then a GET on mail.brilliant.ai must read preview_enabled=false and drop_suppressed_recipients=false, with SPF, DKIM and DMARC confirmed, plus one real delivered message with DKIM pass. Also re-check that staging mail.brilliant.rocks still has both flags false.
Rollback
One-way door (migration and send history). Disable activation first; publication rollback selects a compatible immutable revision. Never replay unknown submissions to simulate delivery.
Auth0 login-code email (shared layout) (#967, merged)
PR #967 (merged 2026-10-15 16:01 IDT by yoni-monday, merge 2a866461, head c357d5ff, branch auth-code-email; opened 15:31 IDT) is not a control-plane outbox send. It brands the Auth0 passwordless one-time-code email with the same Maily + withBaseLayout + EMAIL_THEME stack as Welcome / invitations, then commits the HTML for Pulumi to push onto the Auth0 email connection.
- Renderer:
apps/control-plane/src/email/login-code.ts→ scriptrender-login-code-email.ts→infra/pulumi/src/login-code-email.html. Pulumi replaceshttps://site-origin.placeholderwith the stack's site origin from the Cloudflaredomains.siteconfig (environmentOrigins(...).site, passed intoAuth0Apps/loginScreens). - Subject / preview:
is your Brilliant code(Auth0 Liquid fills the code). withBaseLayoutaccepts any{ content }and alogin_codefooter ("You’re receiving this because someone entered this address to sign in to Brilliant.").- Shared footer links drop
/security(site 301s it home) for every email that uses the layout. - The branded template only reaches inboxes once Auth0 has an external SMTP provider (
loginScreens.smtpProvider→ Cloudflare Email Service). No stack sets the flag yet, so Auth0 still sends its default template; the merge only updated the template and subject. Infra details and owner steps: Hosting & infra — #967. Update: staging set the flag in #972, and prod set it in #974 (merged 2026-10-15 21:00 IDT; live once the prodinfradispatch applies), so prod codes come from[email protected]through Cloudflare SMTP.
Related
Hosting & infra · AUTH0_EMAIL_SMTP_TOKEN · Admin Config · Admin client state · Side environments