Email templates: write the email once, send it with each customer's details
Most transactional emails look the same every time; only the name, the amount or the code changes. JMSURF Mail templates keep the subject, HTML and text in one place so your code sends just the values.
How templates work
In the dashboard, open Templates and create an email with an alias such as order-confirmed. Write the subject, the HTML body and, if you like, a plain-text version. Wherever a value changes per customer, put a placeholder in double braces: {{name}}, {{order}}, {{amount}}.
Your code then sends the alias and the values instead of the full email:
{
"from": "Your Shop <[email protected]>",
"to": "[email protected]",
"template": "order-confirmed",
"variables": { "name": "Wanjiku", "order": "SV-1024", "total": "KES 3,450" }
}JMSURF Mail looks the template up on your account, fills the placeholders and sends the result. If you also send a subject, html or text in the request, yours wins, so you can override one part when needed.
Placeholder rules
| Placeholder | What it does |
|---|---|
{{name}} | Inserts the value. In HTML, special characters are escaped, so a customer name containing < or & cannot break your layout or inject code. |
{{{link_html}}} | Three braces insert the value as it is. Use it only for HTML you built yourself. |
{{customer.name}} | Dotted names reach into objects in variables. |
| A missing value | Becomes empty rather than showing the raw placeholder. |
Templates can be referenced by alias (recommended, readable in code) or by their id.
Why use templates instead of building HTML in code
- Change wording without a release. Fix a typo in a receipt or update a phone number in the footer from the dashboard; the next email uses it.
- One look across systems. If your web app, mobile backend and a cron job all send the same welcome email, they all use the same template.
- Safer output. Escaping is done for you, which removes a common source of broken or unsafe HTML in emails.
- Smaller requests. Your code sends a few values instead of a full HTML document every time.
Templates that most businesses need
- Welcome / confirm your email address
- Password reset link and one-time sign-in code (see password reset and OTP emails)
- Order received, paid, shipped and delivered (see e-commerce emails)
- Invoice and payment receipt, including M-Pesa receipts
- Subscription expiring and renewed (see ISP notifications)
- Fee statements and term notices for schools
Templates and batches
Each item in a POST /emails/batch request can use a template with its own variables, so you can send up to 100 personalised receipts in one call. Templates are included on every paid plan and listed on the pricing page.
Questions
- Can a template have both HTML and plain text?
- Yes. Save both and each email carries both versions, which helps delivery and screen readers.
- What happens if I forget a variable?
- The placeholder becomes empty. The email is still sent, so check your test emails before going live.
Send your first email today
Free plan with 100 emails a month, no card needed. Questions? WhatsApp or call +254 712 504 593, or email [email protected].