> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailofly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates

> Design your emails once, send them forever. Let your marketing team update copy without touching the code.

# Templates 🎨

Imagine your designer builds a beautiful welcome email. You don't want to hardcode that HTML into your app — and you definitely don't want to redeploy every time someone wants to change the wording.

That's what templates are for. Design it in the Mailofly dashboard, give it an ID, and your code just says "send the welcome template to this person with their name filled in." Done.

***

## Why use templates?

* **Your designers and marketers can update copy** without you having to touch a line of code or redeploy
* **Consistent styling** — headers, footers, fonts, and brand colors stay the same across all your emails
* **Dynamic personalization** — swap in any data like `{{first_name}}`, `{{order_id}}`, or `{{plan_name}}` at send time
* **Safe editing** — make changes in draft mode and preview them before going live

***

## Using a template from your code

Instead of passing raw HTML, pass a `template_id` and the variables you want to fill in:

```typescript theme={null}
import { Mailofly } from "@mailofly/node";

const mailofly = new Mailofly("mfly_live_your_api_key");

await mailofly.emails.send({
  from: "Acme <hello@acme.com>",
  to: ["alex@example.com"],
  template_id: "tmpl_welcome_v1",
  variables: {
    first_name: "Alex",
    login_url: "https://acme.com/login?token=abc123xyz",
    support_email: "support@acme.com",
  },
});
```

Mailofly takes your template, fills in all the `{{variables}}`, and sends a beautiful personalized email. Your code never needs to know what the HTML looks like.

***

## Where to go next

* [Create & manage templates](manage-templates.md) — build your first template
* [Template editor guide](template-editor.md) — learn the editor features
* [Variables & personalization](variables.md) — all the merge tag tricks
* [Preview & test](preview-and-test.md) — make sure it looks right before sending


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.