Skip to main content

Email Templates

Email templates allow you to customize transactional communications sent to customers.

Template Fields

FieldDescription
NameTemplate name
SlugUnique identifier
TypeAssociated notification type
SubjectSubject line (supports variables)
HTML bodyHTML content of the email (supports variables)
Text bodyPlain text version (fallback)
VariablesList of variables used
DefaultOne default template per notification type
ActiveWhether the template is available

Variables

Variables are replaced in the subject and body using the syntax \{\{ variable_name \}\}:

VariableDescription
\{\{ customer_name \}\}Customer name
\{\{ invoice_number \}\}Invoice number
\{\{ amount \}\}Currency amount
\{\{ due_date \}\}Due date
\{\{ verification_url \}\}Email verification link
\{\{ reset_url \}\}Password reset link
\{\{ subscription_name \}\}Plan name
\{\{ trial_end_date \}\}Trial end date

Operations

  • Create: New template with name, slug, type, and content
  • Update: Edit subject, body, and variables
  • Duplicate: Copy template with a new slug
  • Delete: Cannot delete the default template
  • Preview: View the template with sample data
  • Set as default: Marks as the default template for the type

Rendering

  1. Gets the template by ID or by type (uses the default)
  2. Loads all variables from the context
  3. Replaces all \{\{ key \}\} patterns with the values
  4. Returns the rendered subject and HTML body

Security

  • Special characters are escaped via regex to prevent ReDoS
  • User input is sanitized before rendering