Merge tags — also called template variables — are placeholders in your email content that MigoSMTP replaces with recipient-specific values at send time. They are the foundation of email personalisation and allow you to send thousands of uniquely personalised emails from a single template without writing a different email for each person.
What Are Merge Tags?
A merge tag is a string enclosed in double curly braces — {{variable_name}} — placed anywhere in your email subject line, HTML body, or plain-text body. When MigoSMTP delivers the email, it replaces the merge tag with the corresponding value you provide in the send request for that recipient.
| In Your Template | Variable Provided | Delivered to Recipient |
|---|---|---|
| Hi {{first_name}}, | first_name = "Rahul" | Hi Rahul, |
| Your order #{{order_id}} | order_id = "12345" | Your order #12345 |
| {{currency}}{{amount}} due | currency = "₹", amount = "1,499" | ₹1,499 due |
| Subject: {{first_name}}, your cart is waiting | first_name = "Priya" | Subject: Priya, your cart is waiting |
Merge Tag Syntax Rules
| Rule | Correct | Incorrect |
|---|---|---|
| Double curly braces, no spaces inside | {{first_name}} | {{ first_name }} |
| Lowercase with underscores for spaces | {{order_total}} | {{Order Total}} |
| Letters, numbers, underscores only | {{product_name_1}} | {{product-name}} |
| Must start with a letter | {{amount}} | {{1amount}} |
| Case-sensitive | {{first_name}} matches "first_name" | {{First_Name}} ≠ "first_name" |
Where Merge Tags Can Be Used
| Location | Example | Supported? |
|---|---|---|
| Subject line | {{first_name}}, your order is confirmed | ✓ |
| Preheader / preview text | Order #{{order_id}} ready for delivery | ✓ |
| HTML body | <p>Hi {{first_name}}</p> | ✓ |
| Plain text body | Hi {{first_name}}, your order... | ✓ |
| Hyperlink URLs | href="{{tracking_url}}" | ✓ |
| Image alt text | alt="{{product_name}} image" | ✓ |
| Image src URLs | src="{{product_image_url}}" | ✓ |
| CSS style attributes | style="color: {{brand_color}}" | Use with caution |
Providing Variable Values in the API
When sending via the Email API with a template, provide variable values per recipient in the variables object:
{
"from": "orders@yourcompany.com",
"to": "rahul@example.com",
"template_id": "order-confirmation-v2",
"variables": {
"first_name": "Rahul",
"order_id": "ORD-98765",
"order_total": "2,499.00",
"currency": "₹",
"delivery_date": "12 June 2026",
"tracking_url": "https://track.yourcompany.com/ORD-98765"
}
}
For bulk sends with different variables per recipient:
{
"from": "orders@yourcompany.com",
"template_id": "order-confirmation-v2",
"recipients": [
{
"to": "rahul@example.com",
"variables": { "first_name": "Rahul", "order_id": "ORD-98765", "order_total": "2,499" }
},
{
"to": "priya@example.com",
"variables": { "first_name": "Priya", "order_id": "ORD-98766", "order_total": "3,299" }
}
]
}
Setting Fallback Values
A fallback value is used when a variable is not provided in the send request — preventing the literal placeholder from appearing in the delivered email:
| Variable | Sensible Fallback | Why |
|---|---|---|
| {{first_name}} | there | Results in "Hi there," — natural and non-broken |
| {{company_name}} | your company | Readable if company name not available |
| {{currency}} | ₹ | Defaults to INR for India-primary audiences |
| {{delivery_date}} | within 5-7 business days | Informative even without a specific date |
Set fallback values in the template settings under Variable Defaults for each declared variable.