Email templates contain the recipient, subject and text of an email for the workflow action **Send Email** (*E-Mail senden*). The text is HTML with placeholders that X-Sitter fills from the order. A workflow only chooses the template. Typical examples are shipping confirmations to end customers or internal notifications.

The emails X-Sitter sends by itself – login details, password reset – are adapted under [System email templates](/company/mail-templates.md).

![Screenshot: Email templates overview with name, client, type, recipient, subject and "Used in workflows"](/automation/images/email-templates-overview.png)

## Before you start

- Your user needs the permissions for **Settings** (*Einstellungen*) and **Email Templates** (*E-Mail-Vorlagen*) in the WMS menu. Opening the form and deleting templates are separate permissions – ask your administrator.
- The client the template is for – see [Clients](/company/clients.md).

## Start from the email library

X-Sitter provides ready-made templates in the **Email library** (*E-Mail-Bibliothek*).

1. In the overview click **From library** (*Aus Bibliothek*).
2. Preview a template with the eye icon.
3. Click **Apply** (*Übernehmen*). X-Sitter creates your own copy for a client, which you can then adapt and select in a workflow.

Copies from the library are marked with a book icon. When X-Sitter publishes a new version of a library template, your copy shows **New version available** (*Neue Version verfügbar*). You can then

- take over subject and text from the new version (sync button), or
- click **Keep** (*Behalten*) to keep your version and hide the notice.

![Screenshot: Email library dialog with ready-made templates and the Apply button](/automation/images/email-templates-library.png)

## Create a template

1. Open **WMS › Settings › Email Templates** (*WMS › Einstellungen › E-Mail-Vorlagen*).
2. Click **New Email Template** (*Neue E-Mail-Vorlage*).
3. In the **Settings** (*Einstellungen*) panel on the right enter the **Template Name** (*Name der Vorlage*), the **Client** (*Mandant*), the **Email Type** (*Mailtyp*) and the **Email Text Format** (*Format des Mailtexts*).
4. Fill in **Recipient (To)** (*Empfänger (An)*), optionally **CC** and **BCC**, and the **Subject** (*Betreff*).
5. Write the **Email text (HTML / Twig)** (*Mailtext (HTML / Twig)*). Helpers in the toolbar:
   - **Insert a block** (*Baustein einfügen*) – ready-made blocks such as salutation, tracking numbers with link, delivery address, item table, closing with company details, or a condition.
   - **Variables** (*Variablen*) – a searchable list of all placeholders ("Search for a variable …"). A click inserts the code at the cursor position.
   - **Insert image** (*Bild einfügen*) – a logo or image from the [media management](/company/media.md).
   - **Basic Framework** (*Grundgerüst*) – inserts a complete starter text for the selected email type.
6. Check the **Preview** (*Vorschau*) with **Sample Data** (*Beispieldaten*) or a **Real Order** (*Echter Auftrag*), and click **Refresh Preview** (*Vorschau aktualisieren*) if needed.
7. Click **Save** (*Speichern*) – or press Ctrl/Cmd + S.
8. In the workflow choose this template under **Send Email** – see [Workflows](/automation/workflows.md).

![Screenshot: Email template editor with recipient, subject, mail text and the toolbar](/automation/images/email-templates-editor.png)

![Screenshot: Variables panel opened next to the mail text with the search field](/automation/images/email-templates-variables.png)

![Screenshot: Email preview with a real order selected](/automation/images/email-templates-preview.png)

## Fields and options

| Field | Meaning |
|---|---|
| **Template Name** (*Name der Vorlage*) | Name shown in the overview and in the workflow, e.g. "Shipping confirmation shop A". |
| **Client** (*Mandant*) | The client the template belongs to. |
| **Email Type** (*Mailtyp*) | **Shipping confirmation to the customer**, **Order confirmation / order received**, **Internal notification** or **Other**. It determines the starter text. |
| **Email Text Format** (*Format des Mailtexts*) | **HTML (line breaks via tags only)** or **Text (every line break is kept)**. |
| **Recipient (To)** (*Empfänger (An)*) | Several recipients separated by commas. Placeholders are allowed, e.g. the customer's email address from the order. |
| **CC** / **BCC** | Additional recipients. |
| **Subject** (*Betreff*) | Subject line, placeholders allowed. |
| **Email text** | The content. It is inserted into your company's mail layout (header with logo). |

## Placeholders

Placeholders are written as the variable name in double curly braces – for example the variable name order.order_number in double curly braces becomes the shop's order number. The easiest way is to insert them from the **Variables** panel. Loops and conditions work the same way as in the [PDF templates](/automation/pdf-documents.md); the ready-made blocks already contain them.

| Group | Examples of variable names |
|---|---|
| Order | order.order_id (internal order number), order.order_number (shop / customer order number), order.external_document_no, order.order_date, order.platform, order.note, order.delivery_name (shipping method), order.item_count |
| Shipment tracking | order.tracking_id (all tracking numbers, comma-separated), order.tracking_links (list with number and url per parcel) |
| Delivery address | order.delivery_address.company, .first_name, .last_name, .street, .house_number, .zip, .city, .country, .country_name, .phone, .email |
| Invoice address | order.invoice_address.company, .first_name, .last_name, .street, .zip, .city, .email |
| Positions | order.items (list) with item.sku, item.name, item.quantity, item.delivered_quantity, item.ean, item.article_number |
| Client | company.name, company.street, company.zip, company.city, company.email, company.telephone, company.website, company.customer_number |
| Logistician | logistician.name, logistician.street, logistician.zip, logistician.city, logistician.email, logistician.telephone |

!!!
For a shipping confirmation, use the customer's email (order.delivery_address.email) as recipient and the block "tracking numbers with link" in the text. In the workflow, tick **Send only once per order** so the customer gets the email only once.
!!!

## Delete a template

Click the delete icon in the overview. A template that is still used in workflows cannot be deleted – the button is disabled ("Still used in workflows"). Choose another template in those workflows first.

## Troubleshooting

| Message | Cause | Solution |
|---|---|---|
| The template is still used in workflows and cannot be deleted: … (*Die Vorlage wird noch in Workflows verwendet …*) | The template is selected in a workflow. | Choose another template in the workflow. |
| The email template was deleted (*Die E-Mail-Vorlage wurde gelöscht*) | Confirmation. | – |
| Warning with a line number when saving (e.g. "Subject, line 1: …") | Syntax error in a placeholder, loop or condition. The template is saved anyway, but the email cannot be sent like this. | Check the named field and line, e.g. missing closing braces, and save again. |
