Emails (mailables)

renderMailable(spec) transforme une spec structurée (salutation, paragraphes, bouton d'action, signature) en un email HTML responsive avec styles en ligne et une version texte — l'expérience « Markdown mail », sans build. Le résultat est exactement le { subject, html, text } attendu par le canal e-mail des notifications.

Astuce
Le contenu utilisateur est échappé en HTML et les URLs d'action sont validées (http/https uniquement) — pas d'injection. Composez-le avec toMail() du module notifications pour envoyer sur plusieurs canaux depuis une seule Notification.

Composez un email pour voir l'aperçu HTML et la version texte.

src/app/examples/mail/page.tsxTSX
import { renderMailable } from "@bext-stack/framework/mail";

const msg = renderMailable({
  subject: "Your receipt",
  greeting: "Hi Ada,",
  intro: ["Thanks for your order — here is your receipt."],
  action: { text: "View receipt", url: "https://app/receipt/42" },
  salutation: "— The Shop",
  brand: { name: "Shop", color: "#16a34a" },
});
// msg: { subject, html, text } — the shape notifications' toMail() wants:

const Receipt = {
  via: () => ["mail"],
  toMail: (u) => renderMailable({ subject: "Receipt", greeting: `Hi ${u.name},`, /* … */ }),
};