SolidX

Email Templates

Learn how to create and manage email templates in SOLID, including dynamic content

Email Templates in SOLID allow you to create and manage HTML/Text based email templates with dynamic content and attachments.

Template Creation

Basic Structure

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{subject}}</title>
</head>
<body>
    Welcome, {{userName}}!
    <p>Thank you for joining our platform.</p>
    <p>Click <a href="{{activationLink}}">here</a> to activate your account.</p>
</body>
</html>

Template Configuration

{
  "name": "welcome_email",
  "subject": "Welcome to {{companyName}}",
  "description": "Welcome email sent to new users",
  "html": "template.html",
  "text": "template.txt",
  "variables": {
    "userName": {
      "type": "string",
      "required": true,
      "description": "User's full name"
    },
    "activationLink": {
      "type": "string",
      "required": true,
      "description": "Account activation link"
    },
    "companyName": {
      "type": "string",
      "default": "SOLID Platform",
      "description": "Company name"
    }
  }
}

Features

Dynamic Content

  • Variable replacement
  • Conditional sections
  • Loop structures
  • Helper functions

Attachments

Static Attachments

{
  "attachments": [
    {
      "filename": "terms.pdf",
      "path": "static/documents/terms.pdf",
      "contentType": "application/pdf"
    }
  ]
}

Dynamic Attachments

{
  "attachments": [
    {
      "filename": "report-{{date}}.pdf",
      "template": "monthly_report",
      "data": {
        "userId": "{{userId}}",
        "month": "{{month}}"
      }
    }
  ]
}

Template Inheritance

Base template:

<!DOCTYPE html>
<html>
<head>
    {% block head %}
    <meta charset="utf-8">
    <style>
        {% block styles %}{% endblock %}
    </style>
    {% endblock %}
</head>
<body>
    <header>{% block header %}{% endblock %}</header>
    <main>{% block content %}{% endblock %}</main>
    <footer>{% block footer %}{% endblock %}</footer>
</body>
</html>

Child template:

{% extends "base.html" %}

{% block content %}
<div>
    {{title}}
    <p>{{content}}</p>
</div>
{% endblock %}

Template Management

Creating Templates

  1. Navigate to Email Templates
  2. Click "New Template"
  3. Configure template:
{
  "name": "order_confirmation",
  "subject": "Order #{{orderNumber}} Confirmation",
  "category": "orders",
  "description": "Sent after successful order placement",
  "variables": {
    "orderNumber": {
      "type": "string",
      "required": true
    },
    "items": {
      "type": "array",
      "required": true
    },
    "total": {
      "type": "number",
      "required": true
    }
  }
}

Testing Templates

{
  "template": "order_confirmation",
  "test": {
    "to": "test@example.com",
    "variables": {
      "orderNumber": "TEST-123",
      "items": [
        { "name": "Product 1", "quantity": 2, "price": 29.99 }
      ],
      "total": 59.98
    }
  }
}

Common Use Cases

Welcome Email

<div>
    Welcome to {{companyName}}
    <p>Dear {{userName}},</p>
    <p>Thank you for joining us! Please verify your email by clicking the button below:</p>
    <a href="{{verificationLink}}">Verify Email</a>
</div>

Order Confirmation

<div>
    Order Confirmation
    <p>Order Number: {{orderNumber}}</p>
    <table>
        {% for item in items %}
        <tr>
            <td>{{item.name}}</td>
            <td>{{item.quantity}}</td>
            <td>{{item.price}}</td>
        </tr>
        {% endfor %}
    </table>
    <p>Total: {{total}}</p>
</div>

Password Reset

<div>
    Password Reset Request
    <p>Click the link below to reset your password:</p>
    <a href="{{resetLink}}">Reset Password</a>
    <p>This link will expire in {{expiryTime}} minutes.</p>
</div>

Best Practices

Design

  • Use responsive layouts
  • Test across email clients
  • Include plain text version
  • Optimize images
  • Follow email standards

Content

  • Clear subject lines
  • Consistent branding
  • Mobile-friendly design
  • Accessible content
  • Valid links

Variables

  • Document all variables
  • Provide defaults when possible
  • Validate data types
  • Handle missing values
  • Use clear naming

Testing

  • Test all variables
  • Check responsiveness
  • Verify attachments
  • Monitor delivery
  • Track engagement