Email sender and reply-to
Slice (a) of Domain and email: the From display name without no-reply, the academy reply-to verified by link, mailboxes by area and how every send maps to an area.
Status: built on branch feat/reply-to-verified (05/10/2026), not released. Owner decision of 05/10 (points 3–4 of the "Domain and email" spec). Plan: docs/CUSTOM_DOMAIN_EMAIL_PLAN.md §7. User guide: Sender and reply-to. Paths are relative to backend/ and web-next/.
1. Rules
- From:
<Academy name> <notification@aladia.io>.senderAddress()(libs/common/src/common/email/reply-to.rules.ts) turns anyno-reply@/noreply@/do-not-reply@local part ofMAIL_FROMintonotification@, so the code is safe even before the env changes. The display name isbranding.email.senderName, else the workspace name, else "Aladia" for system emails. - Reply-To: one main mailbox of the academy (any provider), valid only after a confirmation link; optional mailboxes for teaching, billing, account; an area without a confirmed mailbox uses the main one; with nothing confirmed, the Owner's email.
- Never a member's personal address:
OrganizationBrandingRepository.isMemberPersonalEmailrefuses an address that belongs to a profile who is a member of the academy (not the Owner). - Works today, without a custom domain and without flags.
2. Data and routes
branding.email (organizations and, for the personal workspace, profiles) gains replyToVerifiedAt, replyToCategories.{teaching,billing,account}.{address,verifiedAt}, replyToVerifications[] {address, tokenHash, expiresAt, sentAt} (SHA-256 of a 32-byte token, 48 h) and replyToConfirmationsSent[] (5 a day).
| Route | What |
|---|---|
PUT /v2/organizations/:id/reply-to { slot, address } | save (empty = remove) a mailbox, unconfirmed, and send the link; slot is main, teaching, billing or account |
POST /v2/organizations/:id/reply-to/resend { slot } | new link |
PUT and POST …/resend on /v2/workspaces/personal/reply-to | the same for the personal workspace |
POST /v2/public/reply-to/confirm { token } | public: confirms the address in every slot that uses it; 410 if expired or used |
PATCH …/branding with email.replyTo | still accepted, goes through the same confirmation |
The branding RTO adds email.replyToVerified, email.replyToCategories and email.replyTos (the effective mailboxes, computed by profile with the Owner fallback). The notification only reads replyTos.
web-next: components/settings/branding/reply-to-section.tsx (Settings > Email, Sender section), the public page /confirm-reply-to (explicit button, so link previews in mail clients don't confirm by themselves; public in proxy.ts also with a session).
3. Areas of every send
MAIL_AUDIENCE in reply-to.rules.ts maps every method of NotificationsMailService (inventory of §7.3):
| Area | Sends |
|---|---|
| account | invitations, purchase-link invitation, welcome; verification code and password reset when sent from an academy site |
| teaching | lesson suspended/rescheduled/recording, meeting recordings, certificate |
| billing | payment failed, receipt ready, the 5 subscription cancellation emails |
| system (no academy reply-to) | email changed, password changed, new device, secondary email, account blocked, content removed, webhook failed, free-tier thresholds, custom-domain notices, reply-to confirmation |
resolveEmailSender(org, audience) applies it, called only by MailSenderResolver (§7). The area matters only when there is a workspace: from the hub, code and reset have none and stay Aladia's, without reply-to.
4. Configuration, in order
- Deploy backend, then
scripts/migrations/2026-10-reply-to-verified.js(PHASE=plan, thenPHASE=apply): sparse index onbranding.email.replyToVerifications.tokenHashin organizations and profiles; PLAN lists the reply-to addresses saved before today, which now need a confirmation (until then replies go to the Owner). - On the VPS:
MAIL_FROM=notification@aladia.io(the code already mapsno-reply@tonotification@;aladia.iois authenticated on SendGrid, only the local part changes). Optionally create thenotification@aladia.iomailbox or alias in Google Workspace for stray replies. - Deploy web-next.
5. Tests
tests/unit/reply-to.spec.ts (rules, area map, From without no-reply, resolveEmailSender, the service with an in-memory repository: link, confirmation, expiry, member address refused, reuse of a confirmed address, removal, 5 a day, confirmation email), plus the updated email-layout.spec.ts and organization-branding.spec.ts.
6. References
- Postmark, developer documentation (sender signatures): a sender address is used only after the mailbox clicks a confirmation link.
- SendGrid, Sender identity: single senders are confirmed the same way, by a link sent to the address.
- Google, Email sender guidelines: authentication and sender requirements that the From and Reply-To follow.
7. The sender resolver and the tenant of account emails (L5, L8, L9)
Status: branch release/tenant-emails (06/10/2026). User guide: Your academy's emails.
Flow
browser on app.school.com ──/_api/v2/auth/forgot-password──▶ proxy.ts (Vercel)
Origin: https://app.school.com (+ optional x-aladia-edge-secret signature)
▼
gateway: trustedRequestHost → resolve(host) → MailTenant {id, type, host}
→ (reset) forAccount: customer domain only if the user belongs to the workspace
▼ auth event with tenant
notification: MailSenderResolver.forTenant → RETRIEVE_MAIL_IDENTITY (profile)
→ sender, reply-to, theme, link base → MailService (subuser or aladia.io)The request tenant (gateway)
| File | What |
|---|---|
apps/gateway/src/gateway/libs/request-tenant.ts:80 (trustedRequestHost) | in order: host signed by the proxy when ALADIA_EDGE_SECRET is set (optional; constant-time compare :56, the Origin must match); Origin https://<slug>.aladia.io; Origin of an active custom domain (in-memory trusted-custom-domains list, reloaded every minute), no secret needed. Inactive or unknown domain, hub, x-aladia-tenant alone, or an unsigned x-aladia-tenant-host differing from the Origin: no tenant (hub) |
| Why the Origin is enough | a browser can't forge the Origin; someone forging it with a script can at most make the link go to a verified, active academy domain, and a reset towards a customer domain is sent only if the user is a member of that workspace (forAccount): the same result as a legitimate request from that site. forgot-password rate limits are unchanged |
apps/gateway/…/authentication/mail-tenant.service.ts:60 (fromRequest) | host → workspace with the same WorkspaceAddressGatewayService.resolve the proxy uses (ACTIVE domain or address, custom-domain flag); a left address leads to the new one |
mail-tenant.service.ts:80 (forAccount), :37 (accountTenant) | password reset: a link with the token towards a customer domain only if the user has a privilege on the workspace (staff, teacher, student); <slug>.aladia.io is ours and valid for everyone. The check runs after the response: timing doesn't reveal membership |
auth/auth.controller.ts:115 register, :249 verify-user, :424 resend-verification, :471 forgot-password | pass the tenant to CreateUserDto.mailTenant, ResendCodeDto.mailTenant, WelcomeEmailDto.tenant, PasswordResetTokenDto.tenant |
apps/authentication/…/auth.service.ts:121 (create), :387 (resendVerification) | VerificationCodeDto.tenant; mailTenant is never stored on the user |
libs/common/src/common/email/mail-tenant.ts | MailTenant {id, type, host} and mailTenantOf (defensive read from the queue) |
web-next/proxy.ts:78, lib/tenant.ts:165 (edgeRequestHeaders) | the proxy drops browser x-aladia-* headers and signs only when ALADIA_EDGE_SECRET is set |
The workspace identity (profile)
RETRIEVE_MAIL_IDENTITY (replaces RETRIEVE_EMAIL_BRANDING, which nobody called): organization-branding.service.ts:117 → mail-identity.ts:58 (mailIdentityOf). Returns name, sender name, replyTos, logo and color; emailDomain {address, subuser, region} only with a VERIFIED Email track and the workspace-email-domain flag; siteHost only with an ACTIVE domain and the custom-domain flag; slugHost with the custom-domain flag; branded: false for a personal workspace without branding. Without ownerType (DTOs carrying only the course owner id) it tries the academy, then the personal workspace.
The resolver (notification)
| File | What |
|---|---|
apps/notification/src/app/mail/sender/mail-sender.rules.ts:74 (mailSenderContext) | pure rules: name, reply-to per area, from + subuser onBehalfOf when emailDomain is present (never for templates), theme, whiteLabel |
mail-sender.rules.ts:63 (workspaceLinkBase) | links: the request host if it belongs to the workspace, else the active domain, else FRONTEND_BASE_URL |
mail-sender.rules.ts:111 (rebaseLink) | a link already built on the hub (membership's invitation) moved to the domain |
mail-sender.resolver.ts:76 (resolve), :91 (forTenant) | the single entry point: one-minute cache, 5 s wait, then Aladia |
mail.service.ts:218 (deliverSigned), :193 (subuserMailer) | sending with on-behalf-of: <subuser> on the region host (EU); if the subuser refuses, it is resent right away from notification@aladia.io with the academy's name and reply-to |
mail/layout/email-copy/account.copy.ts | reset, code and welcome (formerly the SendGrid welcome template, now inline) with the academy theme; the body never names Aladia |
SendGrid dynamic templates (36) live on the parent account: a subuser can't see them, so those emails can't leave from the academy's domain. They go through the resolver with template: true: academy name, reply-to and links, From on notification@aladia.io, template body unchanged (Aladia design). Moving them to the domain means rewriting them inline (next lot).
New sends (release/checkout-leads, release/workspace-sso): inject MailSenderResolver, call resolve({ id, type }, { audience }) (or forTenant(dto.tenant, audience) for an email triggered from the site), then mailService.sendInlineEmail(to, content, { sender: context.sender }) with context.theme and context.baseUrl in the copy. No branding reads outside the resolver.
§7.3 inventory
| Kind | Signed by | |
|---|---|---|
| Password reset | inline | academy site (tenant + member for a customer domain) → email domain, brand, links on the site; otherwise Aladia |
| Verification code (sign-up, resend) | inline | academy site → email domain and brand; otherwise Aladia |
| Welcome | inline | sign-up site → brand and links on the site; otherwise Aladia |
| Member invitation, instructions to the technician, reply-to confirmation | inline | workspace → email domain, brand, links on the active domain |
| Purchase-link invitation, receipt, recordings, lesson suspended/rescheduled/recording uploaded, cancellations to the payer | template | workspace name, reply-to and links, from notification@aladia.io |
| Payment failed, certificate, instant meeting recording | template | Aladia: the DTO doesn't carry the seller or issuer |
| Cancellations to the seller's staff | template | Aladia on purpose: Aladia is speaking |
| Email changed, password changed, new device, secondary email, account blocked, content removed, webhook failed, Free thresholds, domain notices, plan billing notices | — | Aladia on purpose (security of the single account, D11; Aladia talking to the customer) |
Configuration
-
No mandatory variable. Optionally, to sign the host on top of the Origin, the same secret on Vercel (project
app-aladia-io, Production) and on the VPS:read -rs ALADIA_EDGE_SECRET # paste a long value (e.g. generated with: openssl rand -hex 32) printf %s "$ALADIA_EDGE_SECRET" | vercel env add ALADIA_EDGE_SECRET production # on the VPS, in /opt/aladia/.env.production: ALADIA_EDGE_SECRET=<value>; then restart the monolithRotation: two comma-separated values on the VPS, then change Vercel, then drop the old one. Without the secret the Origin is used, for active domains and
<slug>.aladia.ioaddresses.The same secret is used by the login attempt limit (
login-rate-limiter.ts,gateway/libs/client-ip.ts): with the secret the proxy also passes the visitor IP (x-aladia-client-ip) and custom domains get the per-IP limit (100 failed attempts in 15 minutes) on top of the per-email one. Without it, custom domains only have the per-email limit (10 in 15 minutes): the IP that arrives is Vercel's, shared by the whole academy. -
Optional:
SENDGRID_ADMIN_API_KEY(parent account key used foron-behalf-of); otherwiseSENDGRID_API_KEY. -
backend/config/common/base/values-prod.yaml:FRONTEND_BASE_URLfixed tohttps://app.aladia.io(plan §1a). -
No migration.
Tests
backend/tests/unit/tenant-emails.spec.ts (trusted host, secret and rotation, spoofing, Origin, unknown domains, members; profile identity with verified, suspended track and flags; resolver with and without domain, templates, reply-to per area, links per host, rebase; branded emails without "Aladia"; subuser sending and fallback; reset end to end in the notification), web-next/lib/tenant.test.mjs (proxy signature). E2E (run by the owner): node web-next/e2e/help/flows/run.mjs account/tenant-emails with TENANT_EMAIL_ACCOUNT, MAILOSAUR_API_KEY, MAILOSAUR_SERVER_ID and, with a verified Email track, TENANT_EMAIL_SENDER_DOMAIN.