Skip to main content

Configure email sending via sSMTP on Linux

For your information

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

  1. Make sure that you have connected the email service for the domain and the domain has the status Verified. You can view connected domains and their statuses in the control panel: in the top menu, click Products → Email Service → resource page → Information tab → Linked domains section.

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

    Connect to the server via SSH or via the KVM console.

  3. Install sSMTP:

    sudo apt update
    sudo apt install ssmtp
  4. Install the auxiliary mailx utility for sending mail:

    sudo apt install mailutils
  5. Install nano:

    sudo apt install nano
  6. Open the ssmtp.conf configuration file:

    nano /etc/ssmtp/ssmtp.conf
  7. Edit the file content:

    mailhub=smtp.servercore-smtp.com:<port>
    AuthUser=<login>
    AuthPass=<password>
    AuthMethod=LOGIN
    rewriteDomain=<example.com>
    hostname=smtp.servercore-smtp.com
    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 no SSL / STARTTLS connection;
      • 1127 — if you need to establish a TLS (SSL) connection.
    • <login> — login, which can be found in the control panel: in the top menu, click Products → Email Service → page of the resource to which the domain is added → Information tab;

    • <password> — password, which can be found in the control panel: in the top menu, click Products → Email Service → page of the resource to which the domain is added → Information tab;

    • <example.com> — domain from which you need to send mailings.

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

  9. Open the revaliases configuration file:

    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:

    root:<sender_email>:smtp.servercore-smtp.com:<port>

    Specify:

    • <sender_email> — sender address on the domain you connected to the email service, for example, sender@example.com;
    • <port> — port 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:

    sudo mv /usr/sbin/sendmail /usr/sbin/sendmail.orig
  13. Create a symlink to ssmtp instead of sendmail:

    sudo ln -s /usr/sbin/ssmtp /usr/sbin/sendmail
  14. Send a test email:

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

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