# Email connection

The email channel transmits new letters received by your inbox via IMAP to the bot. The bot sends a response from the company address via SMTP in the same chain of letters.

!!!note
ChatRex only receives emails that come after connecting the mailbox.
!!!

## Before connecting n

Prepare your email settings with your provider:

- the email from which the bot must respond;
- the name of the sender, such as the name of the company or support department;
- login – this is usually the full email address;
- a separate application password;
- IMAP server address, port and encryption type;
- The address, port and type of SMTP server encryption.

Enable IMAP and SMTP in your mailbox settings. If you have two-factor protection set up for your account, create an application password and use it instead of your usual email password.

!!!warning
Do not provide the primary password from your email account if the provider supports application passwords. Do not add a password to the system prompt or bot knowledge base.
!!!

## Connecting the mailbox

1. In ChatRex, open **Integrations**.
2. Press **Connect integration**.
3. On the **Channels** tab, select **Email** and click **Connect**.
4. Open the tab **Connection installation**.
5. In the **Email account** block, fill in the **Email fields for answers**, **Sendername**, **Login** and **Application password**.
6. In **Incoming emails — IMAP**, specify the server, port and encryption for incoming mail.
7. In **Outgoing emails — SMTP** specify the server, port and encryption for outgoing mail.
8. Press **Connect**.
9. Make sure that the integration settings display the status **Connected**.

The default interface specifies the `993` port and the **SSL/TLS** encryption for IMAP, as well as the `587` and **STARTTLS** port for SMTP. Use your email provider’s values if they differ. The port number is between 1 and 65535.

The password is stored on the server in encrypted form and after saving is no longer shown.

## Designation of a botoo channel

1. Open **My Bots** and press **Change** opposite the desired bot.
2. Go to **Channels and Launch**.
3. In **Conditions on channels** click **Add channel**.
4. Select the connected integration **Email**.
5. Set the launch conditions and save the changes.

## Verification

1. Send a new email to the connected address from another mailbox.
2. Make sure the call appears in **Chats**ChatRex.
3. Check that the bot processed the letter and the reply came to the sender from the specified address and name.
4. Open the email chain and make sure the answer doesn’t create a separate topic.
5. Check the processing in **History**.

For the first check, use test addresses and do not send sensitive data.

## If the mail doesn't connect

Check it out.

- whether IMAP and SMTP are enabled by the postal provider;
- Whether the servers, ports and encryption types are correctly specified;
- whether the login matches the requirements of the provider;
- whether the application password has been created and whether it has not been withdrawn;
- whether third-party email client connections are allowed;
- Does the connection block the corporate firewall?

If the connection is active, but the bot is not responding, check the purpose of the channel to the bot, the launch conditions, the subscription status and the presence of a letter in **Chats**. Also check the **Spam** and **Unsolicited Mail** folders from the recipient.

## Reconnect.

If the application password has changed or been withdrawn, open the Email card in **Integrations**, click **Configure** and enter the new data in the **Connection installation** tab.
