There should be so many reasons if you get the error Error (-1): Connection to server failed while trying to send the emails from the cPanel.
We can fix this error by performing the following steps.
Before starting the troubleshooting of this error, we need to make sure the exim is running. To check it, connect your VPS with SSH using the root user and execute the following command in your terminal.
# service exim status
1. If the exim status is disabled, you will see the below error.
2. Start the exim service by entering the below command.
# service exim start
3. Exim should run fine now.
If exim is running and still you are getting the same error, then please follow the below steps.
1. Open CSF firewall in vi editor.
# vi /etc/csf/csf.conf
2. Commonly, the issue should be with the following code.
SMTP_BLOCK = 1
SMTP_ALLOWLOCAL = 0
3. Change the value in SMTP_ALLOWLOCAL to 1 and restart the CSF firewall.
4. Enter the below command to restart the CSF.
# csf -r
This is now the exim mail server should be working, and you will be able to send the emails from the RoundCube.