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. 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: in the top menu, click ProductsMail Service → resource page → Information tab → Linked domains block.

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

    Connect to the server via SSH or via KVM console.

  3. Install sSMTP:

    sudo apt update
    sudo apt install ssmtp
  4. Install the mailx utility to send emails:

    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 non-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 ProductsMail Service → resource page to which the domain is added → Information tab;

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

    • <example.com> — the domain you want to send emails from.

  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> — 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:

    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 campaign to.