Menu

1 / 3

Changing a mail template used to need a deploy. We built an editor that refuses to publish a broken one

DEV Community: typescript·Marc·2 days ago
#vZCfKXmY
#devtotypescript#devto#dev#mail#template
Reading 0:00
15s threshold

Until recently, changing the wording of a password-reset mail in our framework meant editing a TypeScript file and shipping a release. The same went for the PDF a rental app sends as an invoice. Nobody on the operations side could touch either one.

Looking at why, we found two mail systems that did not know about each other. One stored the mail as a JSON list of sections (text, button) in code, with the branding hardcoded next to it. The other stored a Markdown document in the database and rendered it through MJML, and exactly one app used it. PDFs were a third thing: HTML built in code and printed with Puppeteer. The tenant's logo and colors lived in two places, the static mail branding in app code and the branding tokens per tenant. The mail message type had no concept of attachments or inline images at all.

One model for mail and PDF

Every mail and every PDF is now a template: a slug, a locale, a document, and a small JSON meta object.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.