Skip to main content
Templates let you standardize email layout while personalizing content per recipient and context. Use templates to keep brand structure consistent while still letting campaigns and workflows adapt the message for the recipient. A good template reduces duplicate design work and makes message changes safer to roll out.

Template Types

  • transactional
  • workflow
  • campaign
Choose template type based on sending channel and lifecycle context. If you are unsure, start with the message purpose: transactional templates confirm an action, workflow templates support a timed sequence, and campaign templates support a one-time broadcast.

Variable Basics

MailerPath provides built-in variables for every template send, organized by category: Company and Brand
Contact
Workflow-only
(available only in workflow sends) Links
Alias behavior: Variables support snake_case, camelCase, and lowercase variants automatically. For example, companyName can also be referenced as company_name or companyname. Use canonical names in your templates for clarity.

Using Variables in Transactional Emails

When you send a transactional email, MailerPath automatically populates built-in variables from:
  • Contact record (first name, email, company, etc.)
  • Client settings (brand, sender, timezone, currency, etc.)
  • System defaults (unsubscribe link, view in browser link, etc.)
You reference variables in your template using Handlebars syntax:
All variables are optional; missing contact fields default to empty strings, so your template renders safely even when data is incomplete.

Custom Variables

Custom variables let you send dynamic, application-specific data in addition to the built-in variables. Use them for:
  • Order details (order ID, total, items)
  • Account-specific info (plan name, renewal date, discount code)
  • Dynamic content (personalized recommendations, next steps, status messages)
When you send a transactional email, you provide custom variables in the API request:
In your template, reference custom variables the same way as built-in variables:

How Variables Merge

Custom variables are merged with built-in variables. If your custom variable has the same name as a built-in variable, the custom value takes precedence. Nested objects (maps) merge recursively: Example: Built-in + Custom merge Built-in vars:
Custom vars you send:
Merged result in template:

Custom Variable Naming Rules

Custom variables follow the same alias rules as built-in variables. Use snake_case, camelCase, or lowercase in your templates—they all work:
All three reference the same variable.

Use Cases

1. Transactional order confirmation
2. Account update with personalized content
3. Promotional email with conditional content
In template:

Best Practices for Custom Variables

  1. Use consistent naming: Stick to snake_case across all sends to avoid confusion.
  2. Keep structure simple: 3–4 levels of nesting is ideal; avoid deeply nested structures.
  3. Provide defaults in templates: Use Handlebars conditionals for optional custom vars.
  4. Validate before sending: Ensure email addresses are valid, URLs are formatted, numbers are in expected ranges.
  5. Document your vars: List what custom variables your application will send so template designers know what’s available.

Data Type Support

Custom variables support:
  • Strings: "order_id": "ORD-12345"
  • Numbers: "total": 99.99
  • Booleans: "is_first_purchase": true
  • Arrays: "items": [...]
  • Objects: "shipping": {"address": "...", "cost": 5.00}
Recommended size limit: 16KB total for all custom variables.

Preview Text Guidance

  • preview_text is optional in your template.
  • You can clear preview text by sending null or an empty string.
  • Preview text renders with the same variables as the subject and body, so you can use template variables here too.

Best Practices

  1. Keep a base template per brand or product line: Standardize layouts for consistency.
  2. Test with incomplete data: Test rendering when optional contact fields are missing.
  3. Keep subject lines variable-safe: Ensure subject lines stay readable if a variable is empty.
  4. Include required links: Always include unsubscribe and view-in-browser links for compliance and user experience.
  5. Use conditionals for optional custom vars: Wrap optional custom variables in Handlebars conditionals to handle cases where the data is missing.