Skip to content

Templates

Templates with variables, versions, languages and a preview, kept with your project.

Applies to EngineCloud
View as Markdown
On this page
  1. Versions
  2. Languages
  3. Templates as files
  4. Templates as React components
  5. Sign-in e-mails of Sypnia Data

A template has a name, a subject, an HTML body and an optional text body. Variables use {{name}}; {{#if}}, {{#each}} and escaping work as in Handlebars. If you leave out the text body, it is made from the HTML.

Terminal
npx @sypnia/mail templates create order-ready --subject "Tu pedido {{order}} está listo" --html ./order-ready.html
npx @sypnia/mail templates preview order-ready --data '{"name":"Ana","order":"#1042"}'

Versions

Every change makes a new version; sends use the published one. templates publish order-ready publishes the latest draft, templates rollback order-ready --to 3 goes back. A send can pin a version with template: 'order-ready@3'.

Languages

A template can have a version per language (es, en, pt-BR). The send picks it with locale; without a match it uses the template’s default language.

Templates as files

mail templates pull writes every template to mail/templates/<name>/ (subject.txt, body.html, body.txt, meta.json) and mail templates push sends them back, so templates can live in your repository and be reviewed like code.

Templates as React components

If you prefer writing e-mails as components, @sypnia/mail/react renders them to HTML that mail apps show correctly:

mail/order-ready.tsx
import { Email, Section, Button } from '@sypnia/mail/react';

export default function OrderReady({ name, order }: { name: string; order: string }) {
  return (
    <Email preview={`Your order ${order} is ready`}>
      <Section>Hi {name}, your order {order} is ready to pick up.</Section>
      <Button href="https://laespiga.co/orders">See your order</Button>
    </Email>
  );
}

npx @sypnia/mail templates push renders each component in mail/ and stores the result as a new version of the template with the same name, so sends, versions, languages and previews work exactly as above.

Sign-in e-mails of Sypnia Data

Sypnia Mail is one of the e-mail providers a Sypnia Data project can choose for its sign-in e-mails: confirmations, magic links, codes, password recovery, invitations and e-mail changes. Choose sypnia_mail in the project’s auth settings and give a from address on a domain verified here; nothing else is needed.

  • The words stay in Data. Each type of sign-in e-mail keeps its template in Data, with the variables Data documents; Mail sends what Data writes, from your domain.
  • Everything else is Mail’s. Each e-mail is in the event log with the tag kind=auth.<type>, bounces are suppressed, and the domain’s limits and reputation apply as for any send.
  • Paid like any e-mail. The sends are counted with the rest of your organization’s mail: the first 10 of each month are free, and the rest are paid with your organization’s credits.
  1. Versions
  2. Languages
  3. Templates as files
  4. Templates as React components
  5. Sign-in e-mails of Sypnia Data

    Search pages, sections and terms