[data-reveal]{opacity:1!important;transform:none!important}
AntelopeJS DMS
DocumentationE-mails

E-mails

Server-rendered e-mail templates a module registers in its e-mail entry, how their app config and translations are merged, and what a production build ships for them.

E-mail templates are Vue components that the frontend server renders to HTML when the backend asks for an e-mail. A module registers them apart from its application, in a dms.email.ts entry.

An e-mail entry exports serverEmailTemplates and can export a plain appConfig object, such as shared branding defaults. It must not import the browser frontend module (dms.frontend.ts). The e-mail bundle is built on its own, for Node.js, and verify-source checks that the bundle holds no browser-only module.

Who asks for a render

The backend signs its render requests, and the frontend server verifies them with the e-mail render secret. That secret is the htmlRender.serviceSecret the backend publishes in the manifest, or DMS_HTML_RENDER_SECRET when the manifest carries none. Without either, the server refuses e-mail renders. The render route itself belongs to the DMS, which declares it in its dms.server.ts. A module route renders a template with event.renderEmail(template, props, { locale }).

App config in e-mails

Each render provides useDmsAppConfig(), merged module by module in manifest-priority order. For each module, its e-mail appConfig comes first, then the app/app.config.ts of its layers. The layers of a higher-priority module therefore override the e-mail appConfig of a lower one. Within one module, the e-mail appConfig is the more specific of the two and keeps the values it gives e-mails over the module's own layers.

Public runtime options come from the module manifest. DMS_CLIENT_BASE_URL overrides public.dms.clientBaseUrl, which e-mails use to build links back to the dashboard.

Markup

The rendered HTML carries no Vue hydration comments, such as <!--[-->, <!----> or teleport anchors. An e-mail is never hydrated, so the renderer strips them. It keeps every other comment, Outlook's conditional comments included.

Translations

A production build ships the complete merged translation catalogs as JSON under dist/server/locales/, apart from the executable JavaScript. A deployment ships the whole dist/server directory.

  • Each render loads only its requested language and the English fallback. Every translation key and every module override stays available.
  • An unknown language falls back to English.
  • A missing or corrupt catalog for a supported language fails the render instead of dropping translations without an error.

In development

ajs dms dev also builds the e-mail bundle, once the dev server is ready, and rebuilds it whenever an e-mail template changes. The build runs in a separate process at low priority, so page reloads and hot module replacement never wait for it. A render requested while a build runs waits for that build to finish.

Before it replaces the bundle, a rebuild waits for active renders to finish. New renders wait behind that rebuild, so no render reads files while they are being replaced. A render that waits more than 60 seconds for the build fails instead of reading an incomplete bundle. A render that never finishes can hold up development rebuilds. Production serves the prebuilt bundle and does not use this handoff.

Size budget

verify-source renders eight DMS templates and keeps the e-mail bundle under 256 KiB of JavaScript. It reports the locale data apart:

text
✔ E-mail contracts hold · 8 templates · 132 KB JS (limit 256 KB) · 217 KB locale data