2

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.

aurelius
  • 3,946
  • 7
  • 40
  • 73
user3583721
  • 327
  • 2
  • 4
  • 14
  • You should probably use a transactional email service like Mandrill instead of sending from your server. Sending directly from your server is problematic, because you'll end up having deliverability problems since your server isn't trusted. – hukir Oct 12 '14 at 02:37
  • But the thing is, my server setting blocks outbound SMTP, even using Mandrill does need to send with SMTP... – user3583721 Oct 12 '14 at 05:07
  • Mandrill has an REST API you can use, so you would be able to bypass that problem, which is causing you the same issues here. I've done SMTP from the server before, and it always ends up as a never ending series of issues like the one you're having now. – hukir Oct 12 '14 at 12:20

1 Answers1

12

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

Ansd
  • 1,865
  • 3
  • 19
  • 30