Skip to content

About

Convert email templates from other providers (SendGrid, Mailgun, Mandrill, Postmark, Brevo, Amazon SES) to Mailtrap-compatible Handlebars syntax. Supports single file and bulk directory conversion.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mailtrap Email Template Converter

A hybrid tool that automatically converts email templates from other providers into Mailtrap-compatible Handlebars syntax. Supports single file and bulk directory conversion.

Supported Providers

Provider Template Engine Conversion Complexity
SendGrid Handlebars Low-Medium - convert insert helpers, flag formatDate/comparison helpers
Mailgun Handlebars Low - no syntax changes, API field renaming only
Mandrill (Handlebars) Handlebars Low - no syntax changes, flag mc:edit regions
Mandrill (Merge Tags) Mailchimp *|VAR|* Medium - full merge tag to Handlebars conversion
Postmark Mustachio (Mustache) Low-Medium - convert conditionals {{#var}} to {{#if var}}
Brevo Pongo2/Django High - full template rewrite (different syntax entirely)
Amazon SES Handlebars Low - no syntax changes, API field renaming only

Quick Start

Convert a single template

python3 scripts/converter.py --provider sendgrid --input template.html --output ./converted/

Convert a directory of templates

python3 scripts/converter.py --provider brevo --input ./my-templates/ --output ./converted/

Exit codes

  • 0 - Clean conversion, no flags
  • 1 - Conversion completed with flags (manual review needed)
  • 2 - Error

How It Works

The converter uses a hybrid approach:

  1. Python script (scripts/converter.py) - Handles deterministic regex-based conversions. Fast, reliable for well-defined patterns.
  2. Claude Code skill (SKILL.md) - Orchestrates the script and handles complex edge cases (nested Brevo loops, ambiguous patterns) using LLM intelligence.

What gets auto-converted

  • SendGrid {{insert name "default=X"}} to {{#if name}}{{name}}{{else}}X{{/if}}
  • Mandrill merge tags *|VAR|* to {{var}}
  • Postmark conditionals {{#var}}...{{/var}} to {{#if var}}...{{/if}}
  • Brevo {% if %}, {% for %}, params. prefix, |default: filters
  • And more (see references/conversion-rules.md for full details)

What gets flagged for manual review

  • formatDate helpers (need server-side formatting)
  • Comparison/logical helpers (greaterThan, and, or)
  • Brevo date filters
  • Mandrill mc:edit editable regions
  • Nested loops with ambiguous variable scoping

Output

For each converted file, the script generates:

  • The converted .html file
  • A .report.txt with line-by-line changes and flags

For bulk conversions, a _summary.txt is also generated with totals.

Project Structure

.
├── SKILL.md                        # Claude Code skill definition
├── scripts/
│   └── converter.py                # Python regex converter
├── references/
│   └── conversion-rules.md         # Complete rule reference
├── content/
│   └── how-to-migrate-email-templates.md   # KB article
└── tests/
    ├── input/                      # Test templates (one per provider)
    ├── expected/                   # Expected conversion output
    └── output/                     # Generated output (gitignored)

Accompanying Content

The content/ directory contains a KB article: How to Migrate Email Templates to Mailtrap - a hands-on guide covering template migration from all 6 providers with syntax comparison tables, before/after code examples, and Mailtrap API examples.

Requirements

  • Python 3.6+
  • No external dependencies (stdlib only)

About

Convert email templates from other providers (SendGrid, Mailgun, Mandrill, Postmark, Brevo, Amazon SES) to Mailtrap-compatible Handlebars syntax. Supports single file and bulk directory conversion.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages