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

# Email Templates

> Customize outgoing emails with dynamic template expressions

Templating in outgoing emails allows you to personalize content by embedding dynamic expressions like `{{ .Recipient.FullName }}`. These expressions reference fields from the conversation, contact, recipient, and author objects and dynamically insert the appropriate information when the email is sent.

## Outgoing Email Template Expressions

If you want to customize the look of outgoing emails, you can do so in the **Admin → Templates → Outgoing Email Templates** section. This template will be used for all outgoing emails including replies to conversations, notifications, and other system-generated emails.

### Available Variables

#### Conversation Variables

| Variable                              | Value                                           |
| ------------------------------------- | ----------------------------------------------- |
| `{{ .Conversation.ReferenceNumber }}` | The unique reference number of the conversation |
| `{{ .Conversation.Subject }}`         | The subject of the conversation                 |
| `{{ .Conversation.Priority }}`        | The priority level of the conversation          |
| `{{ .Conversation.UUID }}`            | The unique identifier of the conversation       |

#### Contact Variables

| Variable                   | Value                                 |
| -------------------------- | ------------------------------------- |
| `{{ .Contact.FirstName }}` | First name of the contact/customer    |
| `{{ .Contact.LastName }}`  | Last name of the contact/customer     |
| `{{ .Contact.FullName }}`  | Full name of the contact/customer     |
| `{{ .Contact.Email }}`     | Email address of the contact/customer |

#### Recipient Variables

| Variable                     | Value                          |
| ---------------------------- | ------------------------------ |
| `{{ .Recipient.FirstName }}` | First name of the recipient    |
| `{{ .Recipient.LastName }}`  | Last name of the recipient     |
| `{{ .Recipient.FullName }}`  | Full name of the recipient     |
| `{{ .Recipient.Email }}`     | Email address of the recipient |

#### Author Variables

| Variable                  | Value                               |
| ------------------------- | ----------------------------------- |
| `{{ .Author.FirstName }}` | First name of the message author    |
| `{{ .Author.LastName }}`  | Last name of the message author     |
| `{{ .Author.FullName }}`  | Full name of the message author     |
| `{{ .Author.Email }}`     | Email address of the message author |

## Example outgoing email template

<Note>
  Templates support HTML formatting. Use HTML tags like `<p>` and `<br />` to control spacing and line breaks. Plain text without HTML tags will render without line breaks.
</Note>

```html theme={null}
<p>Dear {{ .Recipient.FirstName }},</p>

{{ template "content" . }}

<p>Best regards,<br />
{{ .Author.FullName }}</p>
---
<p>Reference: {{ .Conversation.ReferenceNumber }}</p>
```

### Understanding Template Structure

When an outgoing email template is configured, it automatically wraps around message content. The `{{ template "content" . }}` placeholder indicates where the message body will be inserted.

#### Template Behavior

The template structure determines what should be included in message responses:

* **Greetings**: If the template includes a greeting (e.g., "Dear `{{ .Recipient.FirstName }}`"), do not add another greeting in the message body
* **Sign-offs**: If the template includes a sign-off (e.g., "Best regards, `{{ .Author.FullName }}`"), do not add another sign-off in the message body
* **Message Content**: Write only the main content that should appear in the `{{ template "content" . }}` section

#### Example: Correct Usage

**Message written in text editor:**

```
Thank you for contacting us. I've reviewed your account and can confirm that your refund has been processed.
```

**Email received by customer:**

```
Dear John,

Thank you for contacting us. I've reviewed your account and can confirm that your refund has been processed.

Best regards,
Sarah Smith
---
Reference: TKT-2024-001
```

#### Example: Incorrect Usage (Duplication)

**Message written in text editor:**

```
Hello John,

Thank you for contacting us. I've reviewed your account and can confirm that your refund has been processed.

Best regards,
Sarah
```

**Email received by customer (with unwanted duplication):**

```
Dear John,

Hello John,

Thank you for contacting us. I've reviewed your account and can confirm that your refund has been processed.

Best regards,
Sarah

Best regards,
Sarah Smith
---
Reference: TKT-2024-001
```

### Adapting to Different Template Configurations

The content structure should match your template configuration:

* **Templates without greetings**: Include your own greeting in the message body
* **Templates with only content placeholder**: Write complete emails including greetings and sign-offs
* **Custom templates**: Review the active template configuration to understand what elements are automatically included
