# How to Configure an SMTP Email Channel in Swarmica
By default, only the IMAP channel for email is available in Swarmica.

This documentation contains instructions for setting up an SMTP channel for email.

## Instructions

:::caution
Before setting up the SMTP channel, make sure that the MX record is set up for the Swarmica hostname in DNS.
:::

1.  Connect to the Swarmica server via SSH as the root user.
2.  Go to the `/root/swarmica` folder:

```bash
cd ~/swarmica
```

1.  Create a backup of the `docker-compose.yml` and `.env` files:

```bash
mkdir backup; cp -a .env docker-compose.yml ./backup
```

1.  Add the following postfix section for the corresponding service in docker-compose.yml:

```txt
  postfix:
    <<: *django
    restart: always
    depends_on:
      - postgres
      - redis
    volumes:
      - swarmica_logs:/swarmica/swarmica/logs:z
      - swarmica_ugc:/swarmica/swarmica/attachments/:z
    env_file:
      - .env
    ports:
      - "25:25"
    command: /start-postfix
    labels:
      - "traefik.enable=false"
```

1.  Add SMTP settings to the `.env` file:

```txt
EMAIL_SERVER_HOSTNAME=<SWARMICA_HOSTNAME>
SMTP_SERVER=<SMTP_RELAY>
SMTP_PORT=<SMTP_RELAY_PORT>
SMTP_USERNAME=<SMTP_RELAY_USER>
SMTP_PASSWORD=<SMTP_RELAY_USER_PASSWORD>
SMTP_NETWORKS=<ALLOWED_NETWORKS_CIDR>
SMTP_USE_TLS=<YES|NO>
```

You can use the same SMTP settings here as for the already configured SMTP Relay in **Swarmica - Settings - SMTP Relay**.

1.  Add the feature flag `__smtp_email_channel` to the `.env` file using this [instruction](https://support.swarmica.com/article/en/596-ficha-flagi-features-vozmozhnost-vklyuchat-i-vyklyuchat-bloki-funkcij-v-swarmica.html).
2.  Restart Swarmica:

```bash
docker compose down; docker compose up -d
```

1.  Log in to the Swarmica UI as Administrator.
2.  Add the SMTP channel in **Settings - Channels - Email - Create - Redirect (SMTP)**:

![](https://support.swarmica.com/attachments/A/I/AI59XJZie9stRRTD_a/image.png)

1.  In the window that appears, specify the channel name, recipient email, and sender email (for example, support@example.tld) and click **Save**:

![](https://support.swarmica.com/attachments/F/-/F-agdE8NY6XCL8X9_a/image.png)

1.  On the SMTP channel settings page that opens, specify the **Sender's name** (for example, swarmica support), enable the channel, fill in the **Outgoing server settings**, or enable the system SMTP server (SMTP Relay) and click **Save**.

![](https://support.swarmica.com/attachments/J/g/JgY_DPOPUoOZ9eq8_a/image.png)