Configure email sending via sSMTP on Linux
This guide explains how to configure email campaigns using the Servercore mail service via the sSMTP utility on a Linux server.
-
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. -
Connect to the server in the Servercore infrastructure from which you plan to send emails:
Dedicated server
Cloud server
Connect to the server via SSH or via the KVM console.
-
Install sSMTP:
Debian / Ubuntu
CentOS
sudo apt updatesudo apt install ssmtp -
Install the auxiliary
mailxutility for sending mail:Debian / Ubuntu
CentOS
sudo apt install mailutils -
Install
nano:Debian / Ubuntu
CentOS
sudo apt install nano -
Open the
ssmtp.confconfiguration file:nano /etc/ssmtp/ssmtp.conf -
Edit the file content:
Debian / Ubuntu
CentOS
mailhub=smtp.servercore-smtp.com:<port>AuthUser=<login>AuthPass=<password>AuthMethod=LOGINrewriteDomain=<example.com>hostname=smtp.servercore-smtp.comFromLineOverride=NoUseSTARTTLS=YesUseTLS=Yes# If <port>=1126, then UseTLS=NoTLS_CA_File=/etc/ssl/certs/ca-certificates.crtSpecify:
-
<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.
-
Close the file ( **Ctrl+X **) and save the changes ( **Y **).
-
Open the
revaliasesconfiguration file:sudo nano /etc/ssmtp/revaliases -
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.
-
Close the file ( **Ctrl+X **) and save the changes ( **Y **).
-
Replace the default mail sender with the configured sSMTP:
sudo mv /usr/sbin/sendmail /usr/sbin/sendmail.orig -
Create a symlink to
ssmtpinstead ofsendmail:sudo ln -s /usr/sbin/ssmtp /usr/sbin/sendmail -
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.