MiniJinja Templating
EuroMail uses MiniJinja as its template engine, which provides Jinja2-compatible syntax familiar to developers who have worked with Python, Ansible, or static site generators. Templates are rendered server-side before SMTP delivery, so recipients receive fully composed HTML emails.
Variable Substitution
Use double curly braces to insert dynamic values into your templates:
<h1>Hello, {{ customer_name }}!</h1>
<p>Your order <strong>#{{ order_id }}</strong> has been confirmed.</p>
When sending an email, pass the variables in the API request body:
{
"from": "[email protected]",
"to": "[email protected]",
"template_id": "order-confirmation",
"variables": {
"customer_name": "Anna",
"order_id": "EM-20260309-4821"
}
}Conditionals, Loops, and Filters
MiniJinja supports control flow and data transformation within templates:
{% if shipping_method == "express" %}
<p>Your order will arrive within 1-2 business days.</p>
{% else %}
<p>Your order will arrive within 5-7 business days.</p>
{% endif %}
<h2>Order Items</h2>
<table>
{% for item in items %}
<tr>
<td>{{ item.name }}</td>
<td>{{ item.quantity }}</td>
<td>{{ item.price | round(2) }} EUR</td>
</tr>
{% endfor %}
</table>
<p>Total: {{ total | round(2) }} EUR</p>
Filters like round, upper, lower, length, and default are available for transforming values inline.
Managing Templates via API
Templates can be created, updated, and versioned through the REST API:
curl -X POST https://api.euromail.dev/v1/templates \
-H "X-EuroMail-Api-Key: em_live_..." \
-H "Content-Type: application/json" \
-d '{
"name": "order-confirmation",
"subject": "Order #{{ order_id }} Confirmed",
"html_body": "<h1>Thanks, {{ customer_name }}!</h1>..."
}'
You can also manage templates through the dashboard, which provides a visual editor with live preview.
Template Versioning
Every update to a template creates a new version. Previous versions are retained, allowing you to roll back if needed. The API returns the current version number with each template response.
Server-Side Rendering
Templates are rendered by the EuroMail worker process immediately before SMTP delivery. This means the recipient's mail client receives a fully rendered HTML email with no template syntax visible. If a required variable is missing, the email is rejected with a clear error message rather than sent with broken placeholders.