> For the complete documentation index, see [llms.txt](https://docs.fortifiedid.se/pipes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fortifiedid.se/pipes/valves/delivery/smtp-valve.md).

# SMTP Valve

Use this valve to send html/plain messages via SMTP.&#x20;

## Prerequisites

Before using this valve the [SmtpClient](broken://spaces/myWE5afSjn7i8nootVe4) module must be configured and deployed.

## Configuration

{% hint style="info" %}
**Valve name:** `SendMail | SendBySmtp | SmtpSender`
{% endhint %}

{% tabs %}
{% tab title="Properties" %}

<table><thead><tr><th width="254">Name</th><th width="277">Description</th><th width="336">Default value</th><th width="119" data-type="checkbox">Mandatory</th><th width="116" data-type="checkbox">Expanded</th></tr></thead><tbody><tr><td><code>smtp_destination</code></td><td>ID of the internal SMTP client used to talk with the SMTP backend. </td><td><code>"default"</code></td><td>false</td><td>false</td></tr><tr><td><code>message_template</code></td><td>Path to a message template file.  The text in the template supports expansion. <a href="#message-template-example">See Message Template example</a></td><td>N/A</td><td>false</td><td>false</td></tr><tr><td><code>subject</code></td><td>Mail subject.</td><td>N/A</td><td>true</td><td>true</td></tr><tr><td><code>mail_from</code></td><td>FROM email address.</td><td>N/A</td><td>true</td><td>true</td></tr><tr><td><code>mail_to</code></td><td>TO email address.</td><td>N/A</td><td>true</td><td>true</td></tr><tr><td><code>mail_cc</code></td><td>CC email address.</td><td>N/A</td><td>false</td><td>true</td></tr><tr><td><code>mail_bcc</code></td><td>BCC email address.</td><td>N/A</td><td>false</td><td>true</td></tr><tr><td><code>remove_prefixes</code></td><td>Array containing prefixes to be removed from email addresses. </td><td>N/A</td><td>false</td><td>false</td></tr><tr><td><code>file_attachment</code></td><td>Path to file. </td><td>N/A</td><td>false</td><td>true</td></tr><tr><td><code>ignore_smtp_timeout</code></td><td>If <code>true</code>, a local SMTP timeout is logged and ignored, and the valve resolves successfully.<br>When <code>false</code>, a local SMTP timeout fails the valve and pipe. </td><td><code>false</code></td><td>false</td><td>false</td></tr></tbody></table>
{% endtab %}

{% tab title="Examples" %}

<pre class="language-json"><code class="lang-json">//Example when sending to 1 to-address.
{
    "name": "SendMail",
    "enabled": true,
    "config": {
        "smtp_destination": "default",
        "subject_parameter": "My Subject",
        "message_template": "C:\\Windows\\Templates\\mail_template.txt",
        "mail_to": "${item.mail}",
        "mail_from": "noreply@mycompany.com",
        "mail_cc": "admin@mycompany.com",
        "file_attachment": "${item.attachment_path}",
        "remove_prefixes": ["SMTP:","sip:"]
    }
}

<strong>//Example when sending to 1 to-address and multiple 
</strong><strong>//cc-adresses stored as multi value.
</strong>{
    "name": "SendMail",
    "enabled": true,
    "config": {
        "smtp_destination": "default",
        "subject_parameter": "My Subject",
        "message_template": "C:\\Windows\\Templates\\mail_template.txt",
        "mail_to": "${item.mail}",
        "mail_from": "noreply@mycompany.com",
        "mail_cc": "@json:${item.cc.all}",
        "file_attachment": "${item.attachment_path}",
        "remove_prefixes": ["SMTP:","sip:"]
    }
}

//Example when sending to multiple hard coded to-addresses.
{
    "name": "SendMail",
    "enabled": true,
    "config": {
        "smtp_destination": "default",
        "subject_parameter": "My Subject",
        "message_template": "C:\\Windows\\Templates\\mail_template.txt",
        "mail_to": "johan@mycompany.com, robert@mycompany.com",
        "mail_from": "noreply@mycompany.com",
        "file_attachment": "${item.attachment_path}",
        "remove_prefixes": ["SMTP:","sip:"]
    }
}

</code></pre>

{% endtab %}
{% endtabs %}

{% hint style="info" %}
`ignore_smtp_timeout` only has effect when the SMTP module has `send_timeout_ms` > `0`; if `send_timeout_ms` = `0`, no local SMTP timeout is generated and this valve setting has no practical effect.
{% endhint %}

## Message Template example

Property expansion is supported with `{{...}}` syntax. All available `item` and `exports` properties can be used in the template. In the example below the item property `generated_otp_value` is generated prior in the pipe.&#x20;

```
<html>
<body>
Your one time password is <b>{{item.generated_otp_value}}</b>
</body>
</html>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fortifiedid.se/pipes/valves/delivery/smtp-valve.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
