---
title: "Configure email sending via sSMTP on Linux"
sidebar_label: "Configure email sending via sSMTP on Linux"
description: "How to configure and test email sending via the sSMTP utility on Linux"
sidebar_position: 4
---

import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import {TabItemLabel} from '@selectel/docux/components'
import Formbricks from '@theme/MDXComponents/Formbricks'

# Configure email sending via sSMTP on Linux

:::info

This guide explains how to configure email campaigns using the Selectel mail service via the sSMTP utility on a Linux server.

:::

1. Ensure that you have connected a mail service for the domain and that the domain has the status `Verified`. You can view connected domains and their statuses in the [control panel](https://my.selectel.ru/ses/): in the top menu, click **Products** → **Mail Service** → resource page → **Information** tab → **Linked domains** block.

2. Connect to the server in the Selectel infrastructure from which you plan to send emails:

   <Tabs queryString="connect-to-server">
     <TabItem value="dedicated-server" default>
       <TabItemLabel>
         Dedicated server
       </TabItemLabel>

       Connect to the server [via SSH](/dedicated/manage/connect-to-server.mdx#connect-via-ssh) or [via KVM console](/dedicated/manage/connect-to-server.mdx#connect-via-kvm-console).
     </TabItem>

     <TabItem value="cloud-server">
       <TabItemLabel>
         Cloud server
       </TabItemLabel>

       Connect to the server [via SSH](/cloud-servers/manage/connect-to-server.mdx#connect-via-ssh) or [via the control panel console](/cloud-servers/manage/connect-to-server.mdx#connect-through-console).
     </TabItem>
   </Tabs>

3. Install sSMTP:

   <Tabs queryString="install-ssmtp">
     <TabItem value="debian-or-ubuntu" default>
       <TabItemLabel>
         Debian / Ubuntu
       </TabItemLabel>

       ```sh
       sudo apt update
       sudo apt install ssmtp
       ```
     </TabItem>

     <TabItem value="centos">
       <TabItemLabel>
         CentOS
       </TabItemLabel>

       ```sh
       sudo yum update
       sudo yum install ssmtp
       ```
     </TabItem>
   </Tabs>

4. Install the `mailx` utility to send emails:

   <Tabs queryString="install-mailx">
     <TabItem value="debian-or-ubuntu" default>
       <TabItemLabel>
         Debian / Ubuntu
       </TabItemLabel>

       ```sh
       sudo apt install mailutils
       ```
     </TabItem>

     <TabItem value="centos">
       <TabItemLabel>
         CentOS
       </TabItemLabel>

       ```sh
       sudo apt install mailx
       ```
     </TabItem>
   </Tabs>

5. Install `nano`:

   <Tabs queryString="install-nano">
     <TabItem value="debian-or-ubuntu" default>
       <TabItemLabel>
         Debian / Ubuntu
       </TabItemLabel>

       ```sh
       sudo apt install nano
       ```
     </TabItem>

     <TabItem value="centos">
       <TabItemLabel>
         CentOS
       </TabItemLabel>

       ```sh
       sudo yum install nano
       ```
     </TabItem>
   </Tabs>

6. Open the `ssmtp.conf` configuration file:

   ```sh
   nano /etc/ssmtp/ssmtp.conf
   ```

7. Edit the file content:

   <Tabs queryString="change-file-content">
     <TabItem value="debian-or-ubuntu" default>
       <TabItemLabel>
         Debian / Ubuntu
       </TabItemLabel>

       ```sh
       mailhub=smtp.mail.selcloud.ru:<port>
       AuthUser=<login>
       AuthPass=<password>
       AuthMethod=LOGIN
       rewriteDomain=<example.com>
       hostname=smtp.mail.selcloud.ru
       FromLineOverride=No
       UseSTARTTLS=Yes
       UseTLS=Yes
       # If <port>=1126, then UseTLS=No
       TLS_CA_File=/etc/ssl/certs/ca-certificates.crt
       ```

       Specify:

       * `<port>` — port:

         * `1126` — if you need to establish a non-SSL / STARTTLS connection; ;
         * `1127` — if you need to establish a TLS (SSL) connection.

       * `<login>` — login, which can be found in the [control panel](https://my.selectel.ru/ses/): in the top menu, click **Products** → **Mail Service** → resource page to which the domain is added → **Information** tab;

       * `<password>` — password, which can be found in the [control panel](https://my.selectel.ru/ses/): in the top menu, click **Products** → **Mail Service** → resource page to which the domain is added → **Information** tab;

       * `<example.com>` — the domain you want to send emails from.
     </TabItem>

     <TabItem value="centos">
       <TabItemLabel>
         CentOS
       </TabItemLabel>

       ```sh
       mailhub=smtp.mail.selcloud.ru:<port>
       AuthUser=<login>
       AuthPass=<password>
       AuthMethod=LOGIN
       rewriteDomain=<example.com>
       hostname=smtp.mail.selcloud.ru
       FromLineOverride=No
       UseSTARTTLS=Yes
       UseTLS=Yes
       # If <port>=1126, then UseTLS=No
       TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt
       ```

       Specify:

       * `<port>` — port:

         * `1126` — if you need to establish a non-SSL / STARTTLS connection; ;
         * `1127` — if you need to establish a TLS (SSL) connection.

       * `<login>` — login, which can be found in the [control panel](https://my.selectel.ru/ses/): in the top menu, click **Products** → **Mail Service** → resource page to which the domain is added → **Information** tab;

       * `<password>` — password, which can be found in the [control panel](https://my.selectel.ru/ses/): in the top menu, click **Products** → **Mail Service** → resource page to which the domain is added → **Information** tab;

       * `<example.com>` — the domain you want to send emails from.
     </TabItem>
   </Tabs>

8. Close the file ( \*\*Ctrl+X \*\*) and save the changes ( \*\*Y \*\*). .

9. Open the `revaliases` configuration file:

   ```sh
   sudo nano /etc/ssmtp/revaliases
   ```

10. Add a line with the address that should be displayed as the sender address in email campaigns via the mail service:

    ```sh
    root:<sender_email>:smtp.mail.selcloud.ru:<port>
    ```

    Specify:

    * `<sender_email>` — the sender address on the domain you connected to the mail service, for example `sender@example.com`;
    * `<port>` — the port you specified in step 7.

11. Close the file ( \*\*Ctrl+X \*\*) and save the changes ( \*\*Y \*\*). .

12. Replace the default mail sender with the configured sSMTP:

    ```sh
    sudo mv /usr/sbin/sendmail /usr/sbin/sendmail.orig
    ```

13. Create a symlink to `ssmtp` instead of `sendmail`:

    ```sh
    sudo ln -s /usr/sbin/ssmtp /usr/sbin/sendmail
    ```

14. Send a test email:

    ```sh
    $ echo test | mail -s "testing ssmtp" <recipient_email>
    ```

    Specify `<recipient_email>` — the address you want to send the test email campaign to.

<Formbricks />
