Email Templates
Email templates allow you to customize transactional communications sent to customers.
Template Fields
| Field | Description |
|---|---|
| Name | Template name |
| Slug | Unique identifier |
| Type | Associated notification type |
| Subject | Subject line (supports variables) |
| HTML body | HTML content of the email (supports variables) |
| Text body | Plain text version (fallback) |
| Variables | List of variables used |
| Default | One default template per notification type |
| Active | Whether the template is available |
Variables
Variables are replaced in the subject and body using the syntax \{\{ variable_name \}\}:
| Variable | Description |
|---|---|
\{\{ 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
- Gets the template by ID or by type (uses the default)
- Loads all variables from the context
- Replaces all
\{\{ key \}\}patterns with the values - Returns the rendered subject and HTML body
Security
- Special characters are escaped via regex to prevent ReDoS
- User input is sanitized before rendering