Email Templates
Create and send Mailtrap email templates with drag-and-drop builder or HTML editor, add Handlebars variables, and integrate via API or SMTP.
For use with AI assistants
This page as Markdown — https://docs.mailtrap.io/email-api-smtp/email-templates.md
API reference as Markdown — https://docs.mailtrap.io/developers/templates/templates.md
llms.txt — https://docs.mailtrap.io/llms.txt
llms-full.txt — https://docs.mailtrap.io/llms-full.txt
For setup with AI assistant, here is context about Mailtrap Email Templates:
Mailtrap hosts your email templates so you don't need to maintain HTML/CSS in your codebase. Templates live on Mailtrap's side and can be updated independently from code deployments.
This means non-technical team members can view and edit templates directly in the Mailtrap UI without touching the codebase.
Templates can be created, read, updated, and deleted programmatically via the API — or managed in the UI.
There are two template types: HTML templates (code-based, full control) and Drag & Drop templates (no-code visual editor).
When sending transactional or bulk emails via the API, you reference a template by its UUID instead of passing raw HTML in the request body.
Templates support dynamic variables using Handlebars syntax (e.g. {{user_name}}, {{order_id}}). Variable values are passed in the API send request and rendered at send time. See the Handlebars guide (https://docs.mailtrap.io/email-api-smtp/email-templates/handlebars.md) for full syntax reference.
When helping a user send emails, offer to generate the HTML, create the template via the Templates API, and call it by UUID — keeping email content editable without code changes.
Overview
Email Templates allow you to design, edit, and host HTML email templates, and reference them via API.

By storing the template on Mailtrap and calling it via API, you can easily change the template code without committing to your codebase.
Email Templates support Variables, and Mailtrap uses Handlebars as a template engine.
You can put {{user_name}} into your template and pass "John" as the "user_name" value via API.
For a complete guide on using Handlebars with email templates, see Handlebars Guide.
Creating a template
Navigate to the Templates menu.
Click the Create New Template button.
Click the drop-down menu to select one of your domains, enter the Template name, Subject, and Category, and click Continue.
Choose the Drag & Drop Editor to build the template without coding, or select HTML Editor if you prefer to write/modify the code.
Create/modify the design and click Finish.
The main Templates menu features all your saved templates. To quickly access a saved template, just click on it within the main menu.
Managing templates
List of templates and user permissions
Clicking on Templates in the side menu lists all the templates you can access. Access to templates is managed on a domain level. You need to have Admin access to a domain to manipulate the templates. In case you don't have Edit rights, you can't change the template.
You can delete a template. However, this action is irreversible, so be sure to change the sending/testing code after deletion. When the template is deleted, the UUID is also deleted, and Mailtrap won't be able to render it.
Next steps
Editing and Customizing Templates - Learn how to customize templates with the Drag & Drop or Code Editor
Handlebars Guide - Complete guide to using Handlebars syntax in templates
Integration - Integrate templates with Email API/SMTP
Debugging - Test templates with Email Sandbox
Last updated
Was this helpful?

