Our Personal Data Server from scratch! tranquil.farm
pds rust database fun oauth atproto

Support HTML/styled notification emails (or configurable templates) #638

Closed oyster.cafe
Closed opened by oyster.cafe

Summary #

Right now every notification email tranquil-pds sends (welcome, password reset, signup verification, email-update) is hardcoded plain text baked into the binary — crates/tranquil-comms/src/locale.rs's STRINGS_* constants — and crates/tranquil-comms/src/email/message.rs sets Content-Type: text/plain unconditionally, with no HTML alternative part.

Running my own instance (haiku.garden, for a small poetry/music community), I'd like these emails to carry basic branding (logo, colors, a friendlier layout) instead of raw plain text. Currently that's impossible without forking and rebuilding the binary, and even then there's no way to change the wording without a fork, since the strings aren't sourced from config or an external template file.

Request #

Ideally, in rough order of usefulness-to-effort:

  1. Multipart HTML + plain-text emails, with a default HTML template that at least applies basic styling (not just a <pre>-style dump of the current plain text) — plain text stays as the fallback part for clients that want it.
  2. Instance-level branding config — e.g. a logo URL / accent color / instance display name in config.toml's [email] section, injected into the default template, so self-hosters don't need to fork just to put their own name/color on it.
  3. (Stretch) template overrides — let an instance point to its own template file(s) on disk for full control, for operators who want to go further than the built-in default.

Happy to help test against a real SMTP relay (Spacemail, in our case) if useful, and can share screenshots of what our current plain-text emails look like in the wild if that helps motivate the default template design.

assuming that it was an LLM that made the issue text, perhaps said LLM could draft one of the 3 proposals outlined as a PR? :p

nel.pet

id say template file preferably tbh. admins should be able to fully control all the content in the emails/discord messages/signal messages/etc!

Sure. I just didn't want to put up a PR without asking. Is the proposed feature interesting in general? -- Torsten

I would really love to be able to send branded emails from my PDS. @tgerke.bsky.social, if its helpful I am very interested in this feature and have a design system so I could publish a PR proposal for the template driven approach. Would you mind if I did?

nel.pet

small pointer here for implementation. tranquil should use a relatively well known existing templating language. like tera or minijinja (though notably not askama since it doesnt support dynamic templates) in the jinja-like corner or something like the rust handlebars port. personally i like the simplicity and extensibility of the handlebars syntax but the jinja-like options work too

Ah I did not see this until post PR. I can look into real templating engines. I leveraged the existing replacement approach with {handle}.

@nel.pet out of curiosity are you thinking we want complex templating where we can inherit/componentize sections like titles etc? If so tera is an easy choice, if not moving to a handlebars is simpler and removes our flavor of interpolation/string replace.

I landed on handle bars due to its simplicity

Here is an initial PR for an example which I was able to prove out in my own project where I swapped over to my forked branch.

@oyster.cafe I think we can close this now that the PR is merged. Thanks again for all the support!

Sign up or Sign in to add to the discussion.