# Email Sender

The Email Sender component drops an email into the middle of a call flow, so the system can fire off notifications, alerts, or caller-specific details automatically as a call runs.

## Overview

Place Email Sender wherever the flow should send a message. You decide which mail server delivers the email and fill in the usual fields: the sender name, the recipients (To, CC, and BCC), the subject, the body, and any attachments.

### Supported mail servers

- **Cloud Voice SMTP Server**: the built-in mail server, ready to use with no extra setup. SMTP (Simple Mail Transfer Protocol) is the standard protocol used to send email.
- **Custom Email Server**: an SMTP server you supply.

:::note
- You can point Email Sender at a mail server from any provider.
- Before a custom server appears as an option here, add it first under **System > Email > Email Server**. Gmail and Outlook both work; follow the matching administrator setup steps to connect either one.
:::

## Configure the component

1. Add the Email Sender component to your call flow, then click it to open its settings.

   ![Email Sender component selected on the call flow canvas](/images/pbx/email-component-cfd.png)

2. Open the **Type of Email Server** list and pick the server that will send the message.

   
   ![Cloud Voice, mail server type list open in the Email Sender settings](/images/pbx/email-server-type-cfd.png)

3. Complete the email fields described below.

4. Click **Confirm** in the bottom-right corner.

### Email fields

**From**

The sender name that recipients see in the email's "From" line.

:::note
Change the default value under **PBX Settings > Preferences > Device Name**.

![Device Name field in PBX preferences](/images/pbx/device-name-cfd.png)
:::

**Subject**

The email subject. Type fixed text, or select the expression button (![expression editor](/images/pbx/fx.png)) to build the value dynamically.

**Email Recipient**

The recipient address, shown in the email's "To" line. Enter addresses directly, or select the expression button to build them from an expression.

:::note
- Up to **5** addresses are allowed; separate them with commas (`,`).
- For expression syntax, see [Variables and Functions in Cloud Voice Expressions](/pbx/call-flow-designer-guide/constants-and-variables-in-cloud-voice-cfd-expression/).
:::

Expression example:

```
FX_TO_STRING($DatabaseAccess1.queryResult)
```

In this case an upstream Database Access component runs `SELECT email_addr FROM user WHERE number='$Session.ani';` to look up the email address tied to the caller's number, and `FX_TO_STRING` converts that result into a string for the recipient field.

**CC**

The carbon-copy address, shown in the email's "Cc" line. Enter addresses directly or build them with an expression.

:::note
- Up to **5** addresses are allowed; separate them with commas (`,`).
- For expression syntax, see [Variables and Functions in Cloud Voice Expressions](/pbx/call-flow-designer-guide/constants-and-variables-in-cloud-voice-cfd-expression/).
:::

**BCC**

The blind-carbon-copy address, shown in the email's "Bcc" line. Enter addresses directly or build them with an expression.

:::note
- Up to **5** addresses are allowed; separate them with commas (`,`).
- For expression syntax, see [Variables and Functions in Cloud Voice Expressions](/pbx/call-flow-designer-guide/constants-and-variables-in-cloud-voice-cfd-expression/).
:::

**Content**

The body of the email. You can embed variables to pull in call or system information:

- For call-related information, select the expression button, build the expression, and insert it into the body.

  ![Expression inserted into the email body to include call information](/images/pbx/email-sender-cfd-variable.png)

- For system-related information, copy the template variable and paste it into the body.

  ![Template variables available for the email body](/images/pbx/pce-template-variable.png)

**Attachments**

Click **Add** to attach a file. For each one, enter an absolute path (or an expression that resolves to a path) that points to a file in the PBX's local storage.

- File path example: `/ysdisk/syslog/pbxlog.log`
- Expression example: `/ysdisk/email/'FX_CONCATENATE("cloudvoice","6602")'`

:::note
- Up to **10** attachments are allowed.
- For expression syntax, see [Variables and Functions in Cloud Voice Expressions](/pbx/call-flow-designer-guide/constants-and-variables-in-cloud-voice-cfd-expression/).
:::

**Do not send email if the attachment file does not exist**

Select this option to skip sending the email whenever any attachment file is missing.

:::caution
An attachment has to already exist in the PBX's local storage: you cannot attach a file from your own computer. If a path (especially one built from an expression) does not resolve to a real file, then with this option enabled the system sends no email at all, which can look like a silent failure. Keep it enabled when paths are built dynamically so recipients never receive an email with a missing attachment.
:::

## Supported connections

Email Sender connects to exactly **one** downstream component. That component can be any of the following:

- [Prompt](/pbx/call-flow-designer-guide/prompt/), Play an audio prompt or a text-to-speech message to the caller.
- [Business Hours](/pbx/call-flow-designer-guide/business-hours/), Route calls to different destinations based on the time of day.
- [Menu](/pbx/call-flow-designer-guide/menu/), Offer callers a set of options and route the call by the DTMF digit they press. DTMF (Dual-Tone Multi-Frequency) is the tone a phone sends when a key on the dial pad is pressed.
- [User Input](/pbx/call-flow-designer-guide/user-input/), Collect DTMF digits from the caller, typically paired with Condition to route on what they enter.
- [Language](/pbx/call-flow-designer-guide/language/), Switch the system-prompt language for the components that follow.
- [Record](/pbx/call-flow-designer-guide/record/), Start recording once the caller connects to another party (with optional notice prompts), or suppress recording for calls that would otherwise be recorded.
- [Dial by Number](/pbx/call-flow-designer-guide/dial-by-number/), Let callers dial a number directly to reach their destination.
- [Dial by Name](/pbx/call-flow-designer-guide/dial-by-name/), An end component that lets callers reach a user by entering the first three letters of the user's name.
- [Transfer](/pbx/call-flow-designer-guide/transfer/), An end component that transfers the caller to a set destination, with optional notice prompts.
- [Hang Up Call](/pbx/call-flow-designer-guide/hang-up-call/), An end component that disconnects the call.
- [Condition](/pbx/call-flow-designer-guide/condition/), Route calls using logical expressions.
- [Loop](/pbx/call-flow-designer-guide/loop/), Run a group of components repeatedly, either a set number of times or until a condition is met.
- **Internal Data Ops**: Query and update data in the PBX-native database. See:
  - [Get Extension Presence Status](/pbx/call-flow-designer-guide/get-extension-presence-status/)
  - [Set Extension Presence Status](/pbx/call-flow-designer-guide/set-extension-presence-status/)
  - [Get Queue Agent](/pbx/call-flow-designer-guide/get-queue-agent/)
  - [Get Queue Info](/pbx/call-flow-designer-guide/get-queue-info/)
  - [Get Agent Status](/pbx/call-flow-designer-guide/get-agent-status/)
  - [Set Agent Status](/pbx/call-flow-designer-guide/set-agent-status/)
  - [Get System Info](/pbx/call-flow-designer-guide/get-system-info/)
  - [Get System Capacity](/pbx/call-flow-designer-guide/get-system-capacity/)
  - [Get Extension Info](/pbx/call-flow-designer-guide/get-extension-info/)
  - [Get Company Contact Info](/pbx/call-flow-designer-guide/get-company-contact-info/)
- [Email Sender](/pbx/call-flow-designer-guide/email-sender/), Send another email for notifications, alerts, or user-specific information.
- [Database Access](/pbx/call-flow-designer-guide/database-access/), Run SQL against a database to retrieve or update data during the flow.
- [HTTP Request](/pbx/call-flow-designer-guide/http-request/), Send HTTP requests to external servers to exchange data with third-party services.
