TutorialsCreate an Email Template

Create an Email Template

Build a beautiful, reusable email template for your emails.


Overview

This tutorial guides you through creating a professional email template. You’ll learn:

  • How to quickly generate templates using AI
  • How to import pre-built templates from the Template Gallery
  • How to manually build templates with the drag-and-drop designer
  • Working with dynamic variables for personalization
  • Preview and publish your template

By the end, you’ll have a reusable order confirmation template that you can send via the API.


Prerequisites

Before starting, make sure you have:

  • An active FormaMail account
  • Access to the dashboard
  • (Optional) A logo or images for your template

Choose Your Approach

FormaMail offers three ways to create templates. Choose the one that works best for you:

ApproachBest ForTime
AI GenerationQuick start, common use cases~1 minute
Template GalleryProfessional designs, inspiration~2 minutes
Manual DesignFull customization, unique layouts~10-15 minutes

Recommendation: Start with AI generation or the Template Gallery to get up and running quickly. You can always customize the result afterward.


Option A: Generate with AI (Fastest)

Let AI create your template in seconds:

Step 1: Start AI Generation

  1. Log in to your FormaMail Dashboard
  2. Go to Templates β†’ Create Template
  3. Click Generate with AI

Step 2: Describe Your Template

Enter a natural language description of what you need. Be specific for better results:

Example prompts:

β€œOrder confirmation email with company logo header, order number, list of purchased items with prices, order total, shipping address, and a track order button”

β€œWelcome email for new SaaS users with a friendly greeting, 3 key features with icons, and a get started button”

β€œPassword reset email with security warning, reset link button, and note about link expiration”

Step 3: Review and Customize

  1. AI generates a complete template with:
    • Professional layout and styling
    • Appropriate components
    • Pre-configured variables (e.g., {{customerName}}, {{orderNumber}})
  2. Review the generated template in the designer
  3. Make any adjustments:
    • Update colors to match your brand
    • Replace placeholder logo with your own
    • Modify text content
    • Add or remove sections

Step 4: Publish

  1. Click Preview to test the template
  2. Click Save to save your draft
  3. Click Publish to make it available for sending
  4. Copy the Template ID for use in your code

Pro tip: You can continue to refine the template with AI. Just describe the changes you want: β€œAdd a footer with social media links” or β€œMake the header background blue”.


Browse and import professionally designed templates:

  1. Log in to your FormaMail Dashboard
  2. Go to Templates β†’ Template Gallery

Step 2: Find a Template

Browse by category:

  • Transactional: Order confirmations, shipping updates, receipts
  • Marketing: Newsletters, promotions, announcements
  • Notifications: Alerts, reminders, account updates
  • Welcome: Onboarding, welcome series

Or search for specific templates like β€œinvoice”, β€œpassword reset”, or β€œnewsletter”.

Step 3: Preview and Import

  1. Click on a template to preview it
  2. Review the included variables and structure
  3. Click Import to add it to your templates

Step 4: Customize

  1. The template opens in the designer
  2. Update the branding:
    • Replace the logo
    • Adjust colors to match your brand
    • Update company information
  3. Modify content as needed
  4. Add or remove sections

Step 5: Publish

  1. Click Preview to test
  2. Click Save and Publish
  3. Copy the Template ID

Option C: Build Manually (Full Control)

For complete customization, build your template from scratch using the drag-and-drop designer.

Tutorial: Create an Order Confirmation Template

Step 1: Navigate to Templates

  1. Log in to your FormaMail Dashboard
  2. Click Templates in the sidebar
  3. Click the Create Template button
  4. Select Email Template

You’ll be taken to the template designer with a blank canvas.

Step 2: Set Template Details

Before designing, set the basic template information:

  1. Click the Settings icon (gear) in the top toolbar
  2. Fill in the template details:
    • Name: Order Confirmation
    • Slug: order-confirmation (auto-generated, used in API)
    • Description: Sent to customers after successful order placement
    • Subject: Order Confirmed - #{{orderNumber}}

Variable in Subject: Notice {{orderNumber}} in the subject line. This will be replaced with the actual order number when you send the email.

Step 3: Add a Header Section

Let’s start with a branded header:

  1. From the Component Library (left panel), drag a Container onto the canvas

  2. With the container selected, set these properties in the right panel:

    • Background Color: #1a1a2e (dark blue)
    • Padding: 24px
  3. Drag an Image component into the container

  4. Click Select from Gallery (or enter your logo URL)

  5. Set image properties:

    • Width: 150px
    • Alignment: Center
    • Alt Text: Company Logo
  6. Drag a Heading component below the image

  7. Set heading properties:

    • Content: Order Confirmed!
    • Level: H1
    • Text Color: #ffffff
    • Text Align: Center

Step 4: Add the Order Summary

Now add the main content area:

  1. Drag a new Container below the header

  2. Set container properties:

    • Background Color: #ffffff
    • Padding: 32px
  3. Add a Text component with:

    • Content: Hi {{customerName}},
    • Font Size: 18px
    • Margin Bottom: 16px
  4. Add another Text component:

    • Content: Thank you for your order! We're preparing your items for shipment.
    • Font Size: 16px
    • Text Color: #666666

Step 5: Add Order Details Box

Create a highlighted box for order information:

  1. Drag a Container inside the content area

  2. Set properties:

    • Background Color: #f8f9fa
    • Border Radius: 8px
    • Padding: 20px
    • Margin Top: 24px
  3. Add a Heading component:

    • Content: Order Details
    • Level: H3
    • Margin Bottom: 16px
  4. Add Text components for each detail:

Order Number: {{orderNumber}}
Order Date: {{orderDate}}
Payment Method: {{paymentMethod}}

Use the Divider component between sections for visual separation.

Step 6: Add Order Items with Loop

For dynamic order items, use a Loop component:

  1. Drag a Loop component into the content area

  2. Set the Data Source to {{items}}

  3. Inside the loop, add a Columns component (2 columns)

  4. In the left column, add:

    • Text: {{item.name}}
    • Text: Qty: {{item.quantity}} (smaller, gray text)
  5. In the right column, add:

    • Text: {{item.price}}
    • Text Align: Right
    • Font Weight: Bold

Loop Variables: Inside a loop, access item properties with {{item.propertyName}}. The item prefix is automatically added.

Step 7: Add Order Total

Below the items loop:

  1. Add a Divider component

  2. Add a Columns component (2 columns)

  3. Left column - Text:

    • Content: Subtotal:
    • Font Weight: Normal
  4. Right column - Text:

    • Content: {{subtotal}}
    • Text Align: Right
  5. Repeat for Shipping and Tax

  6. Add another row for Total with:

    • Font Size: 18px
    • Font Weight: Bold
    • Content (left): Total:
    • Content (right): {{total}}

Step 8: Add Call-to-Action Button

Add a button for customers to track their order:

  1. Drag a Button component below the totals
  2. Set properties:
    • Text: Track Your Order
    • URL: {{trackingUrl}}
    • Background Color: #4f46e5 (indigo)
    • Text Color: #ffffff
    • Padding: 12px 32px
    • Border Radius: 6px
    • Alignment: Center
    • Margin Top: 24px

Create a professional footer:

  1. Drag a new Container for the footer

  2. Set properties:

    • Background Color: #f8f9fa
    • Padding: 24px
    • Text Align: Center
  3. Add Text component:

    • Content: Questions? Contact us at {{supportEmail}}
    • Font Size: 14px
    • Text Color: #666666
  4. Add another Text:

    • Content: Β© {{__CURRENT_YEAR__}} {{companyName}}. All rights reserved.
    • Font Size: 12px
    • Text Color: #999999

System Variables: {{__CURRENT_YEAR__}} is a system-provided variable that automatically inserts the current year. No need to pass it when sending!

Step 10: Review Variables

Click the Variables tab in the right panel to see all detected variables:

VariableTypeDescription
customerNameStringCustomer’s name
orderNumberStringOrder identifier
orderDateStringDate of order
paymentMethodStringPayment method used
itemsArrayOrder line items
subtotalStringOrder subtotal
shippingStringShipping cost
taxStringTax amount
totalStringOrder total
trackingUrlStringOrder tracking link
supportEmailStringSupport email
companyNameStringYour company name

Step 11: Preview Your Template

Test how your template looks:

  1. Click the Preview button in the toolbar
  2. Switch between Desktop and Mobile views
  3. Click Test Data to enter sample values
  4. Verify all variables render correctly

Example test data:

{
  "customerName": "John Doe",
  "orderNumber": "ORD-12345",
  "orderDate": "December 7, 2025",
  "paymentMethod": "Visa ending in 4242",
  "items": [
    { "name": "Wireless Headphones", "quantity": 1, "price": "$99.99" },
    { "name": "Phone Case", "quantity": 2, "price": "$29.98" }
  ],
  "subtotal": "$129.97",
  "shipping": "$5.99",
  "tax": "$10.80",
  "total": "$146.76",
  "trackingUrl": "https://example.com/track/12345",
  "supportEmail": "support@example.com",
  "companyName": "Acme Electronics"
}

Step 12: Save and Publish

  1. Click Save to save your draft
  2. Click Publish to make the template available for sending
⚠️

Draft vs Published: Only published templates can be used to send emails. You can continue editing a published template - changes won’t affect sent emails until you publish again.

  1. Copy your Template ID for use in your code:
    • UUID: 550e8400-e29b-41d4-a716-446655440000
    • Slug: order-confirmation

Using Your Template

Now send emails using your new template:

const response = await axios.post(
  'https://api.formamail.com/api/emails/send',
  {
    templateId: 'order-confirmation',  // or use the UUID
    to: [{ email: 'customer@example.com', name: 'John Doe' }],
    variables: {
      customerName: 'John Doe',
      orderNumber: 'ORD-12345',
      orderDate: 'December 7, 2025',
      paymentMethod: 'Visa ending in 4242',
      items: [
        { name: 'Wireless Headphones', quantity: 1, price: '$99.99' },
        { name: 'Phone Case', quantity: 2, price: '$29.98' }
      ],
      subtotal: '$129.97',
      shipping: '$5.99',
      tax: '$10.80',
      total: '$146.76',
      trackingUrl: 'https://yoursite.com/track/12345',
      supportEmail: 'support@yourcompany.com',
      companyName: 'Your Company'
    }
  },
  {
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json'
    }
  }
);

Component Reference

Commonly Used Components

ComponentUse CaseKey Properties
TextParagraphs, descriptionscontent, fontSize, color, align
HeadingTitles, section headerscontent, level (H1 to H6), color
ButtonCall-to-action linkstext, url, backgroundColor, color
ImageLogos, product imagessrc, alt, width, alignment
ContainerGroup components, backgroundsbackgroundColor, padding, borderRadius
ColumnsSide-by-side layoutscolumnCount (2 to 4), gap
DividerVisual separationcolor, thickness, margin
LoopRepeat for arraysdataSource, itemVariable
ConditionalShow/hide contentcondition

Layout Tips

Two-Column Layout Example:

Columns (2 columns)
β”œβ”€β”€ Column 1
β”‚   └── Image (product photo)
└── Column 2
    β”œβ”€β”€ Heading (product name)
    β”œβ”€β”€ Text (description)
    └── Button (buy now)

Card Pattern:

Container (background, padding, border-radius)
β”œβ”€β”€ Heading
β”œβ”€β”€ Text
└── Button

Best Practices

Design

  1. Keep it simple - Avoid overly complex layouts
  2. Mobile-first - Design for mobile, then adjust for desktop
  3. Consistent spacing - Use uniform padding and margins
  4. Brand colors - Stick to 2-3 primary colors
  5. Readable fonts - 14-16px for body text, 24-32px for headings

Variables

  1. Descriptive names - Use customerFirstName not fn
  2. Provide defaults - Handle missing variables gracefully
  3. Test thoroughly - Preview with sample data before publishing
  4. Document variables - Keep a list of required variables

Email Client Compatibility

  1. Use web-safe fonts - Arial, Helvetica, Georgia, Times New Roman
  2. Limit width - Max 600px for main content
  3. Include alt text - For all images
  4. Test across clients - Gmail, Outlook, Apple Mail, mobile

Advanced Features

Conditional Content

Show content based on conditions:

  1. Drag a Conditional component
  2. Set Condition: {{hasDiscount}}
  3. Add content inside that only shows when condition is true

Example: Show discount badge only for discounted orders:

Condition: {{hasDiscount}}
└── Container (badge style)
    └── Text: "You saved {{discountAmount}}!"

Nested Objects

Access nested data with dot notation:

Customer: {{customer.name}}
Address: {{customer.address.street}}, {{customer.address.city}}

Formatting

Use JavaScript expressions for formatting:

Date: {{formatDate(orderDate, 'MMMM D, YYYY')}}
Price: {{formatCurrency(amount, 'USD')}}

Iterative AI Editing

After creating a template (manually or via AI), you can use AI to make changes:

  1. Open your template in the designer
  2. Click Edit with AI
  3. Describe the changes you want:
    • β€œAdd a promotional banner at the top”
    • β€œChange the button color to green”
    • β€œAdd a section showing related products”
  4. AI applies the changes while preserving your existing content

See the AI Template Editing tutorial for more advanced AI editing techniques.


Troubleshooting

Template Not Saving

Solutions:

  1. βœ… Check for validation errors in components
  2. βœ… Ensure all required fields are filled
  3. βœ… Check your internet connection
  4. βœ… Try refreshing and re-saving

Variables Not Rendering

Solutions:

  1. βœ… Verify syntax: {{variableName}} with double curly braces
  2. βœ… Check variable names are exact (case-sensitive)
  3. βœ… Ensure the variable is passed when sending
  4. βœ… Check the Variables tab for detected variables

Layout Issues on Mobile

Solutions:

  1. βœ… Use responsive column layouts (they stack on mobile)
  2. βœ… Keep button text short
  3. βœ… Use percentage widths for images
  4. βœ… Preview in mobile mode before publishing

Images Not Displaying

Solutions:

  1. βœ… Use HTTPS URLs for external images
  2. βœ… Upload images to Asset Gallery for best results
  3. βœ… Include alt text for broken image fallback
  4. βœ… Keep image file sizes small (under 200KB)

Template Ideas

Looking for inspiration? Here are common template types:

Transactional Emails

  • Order confirmation
  • Shipping notification
  • Password reset
  • Account verification
  • Receipt/invoice

Marketing Emails

  • Welcome series
  • Newsletter
  • Product announcement
  • Sale notification
  • Re-engagement

Notification Emails

  • Appointment reminder
  • Payment due
  • Subscription expiring
  • Activity summary
  • Alert notification

Next Steps

Now that you’ve created your first template: