Configure CSF to allow outbound SMTP

user3583721 picture user3583721 · Oct 12, 2014 · Viewed 13.6k times · Source

I have a web app that sends email via SMTP (Gmail, Zoho Mail servers). The thing is, the email sending works in my localhost but not on my VPS (using WHM).

I contacted support and the guy replied:

If your VPS has ConfigServer Firewall (CSF) installed then this would most likely be causing the problem. As it is working on localhost but not externally this certainly sounds like it might be the case. You will need to review the firewall configuration on the VPS and ensure hose ports are allowed outbound.

But when it comes to server management and configuration, I'm totally lost. I did check the CSF settings page on WHM but not sure where to start.

Any recommendation or solution would be appreciated.

Answer

Ansd picture Ansd · Dec 1, 2014

You have to allow outgoing traffic to ports 25, 465, 587 and in the case of Mandrill 2525 as will. You should actually be fine enabling only the one you will connect to. So:

sudo vim /etc/csf/csf.conf

add 25,2525,465,587 to TCP_OUT, and to TCP6_OUT if you use IPv6.

You might also need to remove that ports from SMTP_PORTS if you have SMTP_BLOCK enabled (if it is set to 1).

Source: https://community.centminmod.com/threads/csf-firewall-info.25/#post-6613