๐Ÿ“ง MailGen

Upload HTML email templates โ†’ Get email rendering API endpoints instantly

๐Ÿ“‹ My Templates

๐Ÿ“ญ

No templates yet

๐Ÿ‘ˆ

Select a template to view details

Or upload a new one to get started

๐Ÿ“ค Upload HTML Email Template

Upload an HTML email file with {{variable}} Handlebars placeholders. MailGen will parse it and create a dedicated email rendering API endpoint with automatic CSS inlining.

โœ‰๏ธ

Drop your HTML email template here or click to browse

๐Ÿงช Test Email Rendering

Inline CSS (for email clients)
JSON response

๐Ÿ‘ Email Preview

๐Ÿš€ How MailGen Works

1

Upload HTML

Upload an HTML email template with {{variable}} Handlebars placeholders for dynamic content.

2

Get Schema

MailGen parses your template and generates a JSON payload schema showing all required variables.

3

Call API

POST your data to the generated endpoint. MailGen renders the HTML with your data and inlines CSS.

4

Get Email HTML

Receive email-ready HTML with inlined CSS โ€” compatible with all major email clients.

๐Ÿ“š API Reference

๐Ÿ“ก Endpoints
GET /api/templates โ€” List all templates POST /api/templates โ€” Upload new template (multipart: html file + name) GET /api/templates/:slug โ€” Get template details, schema & sample payload GET /api/templates/:slug/source โ€” Get raw HTML source with {{placeholders}} POST /api/templates/:slug/render โ€” Render email HTML (JSON body = template data) POST /api/templates/:slug/preview โ€” Preview rendered HTML (no CSS inlining) DEL /api/templates/:slug โ€” Delete a template GET /healthz โ€” Health check
โš™๏ธ Render Options (query params on /render)
?inlineCss=true|false โ€” Inline CSS styles (default: true, recommended for email) &format=json โ€” Return JSON wrapper with { html, template, renderedAt }
โœ๏ธ Template Syntax (Handlebars)
Simple variable: {{companyName}} Nested object: {{address.city}} Loop: {{#each items}} ... {{name}} ... {{/each}} Conditional: {{#if showDiscount}} ... {{/if}} Helpers: {{uppercase name}} {{lowercase status}} {{year}} {{now}}
๐ŸŽฏ Built-in Helpers
{{eq a b}} โ€” Equality check {{neq a b}} โ€” Not equal {{gt a b}} โ€” Greater than {{lt a b}} โ€” Less than {{and a b}} โ€” Logical AND {{or a b}} โ€” Logical OR {{uppercase str}} โ€” Convert to UPPERCASE {{lowercase str}} โ€” Convert to lowercase {{year}} โ€” Current year (e.g. 2026) {{now}} โ€” Today's date (YYYY-MM-DD)
๐Ÿ’ป Quick Start Example
# 1. Upload a template curl -X POST /api/templates \ -F "html=@welcome-email.html" \ -F "name=Welcome Email" # 2. Render email HTML curl -X POST /api/templates/welcome-email/render \ -H "Content-Type: application/json" \ -d '{"recipientName":"John","companyName":"Acme"}' \ --output welcome.html # 3. Or get JSON response curl -X POST /api/templates/welcome-email/render?format=json \ -H "Content-Type: application/json" \ -d '{"recipientName":"John","companyName":"Acme"}'

๐Ÿ’ก CSS Inlining

MailGen uses Juice to automatically inline <style> blocks into element-level style="" attributes. This ensures maximum compatibility with email clients like Gmail, Outlook, and Apple Mail, which strip <style> tags. CSS inlining is enabled by default on the /render endpoint. Use ?inlineCss=false to disable it.