Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Here is the thing, my server fails to connect to gmail SMTP with timeout error. I think the 465 port is closed on my server so I did couple of thing, now my csf.config file hase this two lines:

TCP_IN = "20,21,22,25,53,80,110,143,443,465,587,993,995,2011,2222,8080"
TCP_OUT = "20,21,22,25,53,80,110,113,443,2011,2222,8080,465"

and I searched the iptable file for 465 and there is three occurance like so:

-A INPUT -p tcp -m tcp --dport 465 --tcp-flags FIN,SYN,RST,ACK SYN -j ACCEPT
-A INPUT ! -i lo -p tcp -m state --state NEW -m tcp --dport 465 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 465 -j ACCEPT

when I run netstat -tulpn command I get this result:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 158.58.184.42:53            0.0.0.0:*                   LISTEN      1938/named
tcp        0      0 127.0.0.1:53                0.0.0.0:*                   LISTEN      1938/named
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1552/sshd
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      1681/exim
tcp        0      0 0.0.0.0:443                 0.0.0.0:*                   LISTEN      9671/httpd
tcp        0      0 0.0.0.0:993                 0.0.0.0:*                   LISTEN      1505/dovecot
tcp        0      0 0.0.0.0:995                 0.0.0.0:*                   LISTEN      1505/dovecot
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      1689/mysqld
tcp        0      0 0.0.0.0:587                 0.0.0.0:*                   LISTEN      1681/exim
tcp        0      0 0.0.0.0:110                 0.0.0.0:*                   LISTEN      1505/dovecot
tcp        0      0 0.0.0.0:143                 0.0.0.0:*                   LISTEN      1505/dovecot
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      9671/httpd
tcp        0      0 :::21                       :::*                        LISTEN      1817/proftpd
tcp        0      0 :::22                       :::*                        LISTEN      1552/sshd
tcp        0      0 :::25                       :::*                        LISTEN      1681/exim
tcp        0      0 :::587                      :::*                        LISTEN      1681/exim
tcp        0      0 :::2222                     :::*                        LISTEN      1675/directadmin
udp        0      0 158.58.184.42:53            0.0.0.0:*                               1938/named
udp        0      0 127.0.0.1:53                0.0.0.0:*                               1938/named

The server ip is : 158.58.184.42 and smtps port (465) is not open yet! What should I do?

share|improve this question

closed as off-topic by 84104, Jenny D, Falcon Momot, dawud, Scott Pack Oct 10 '13 at 15:45

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – 84104, Jenny D, Falcon Momot, dawud, Scott Pack
If this question can be reworded to fit the rules in the help center, please edit the question.

2  
Is your server trying to connect (send) to gmail? Or is it the other way around? Your question doesn't make sense that way it's currently written. –  MDMarra Oct 9 '13 at 23:56
    
@MDMarra ~ I am trying to send emails through gmail SMTP. I wrote the code in PHP. but the fsockopen function gives error unable to connect to smtp.gmail.com:465 (Connection timed out) –  safaali Oct 10 '13 at 0:00
2  
Your outgoing connections have nothing to do with your incoming firewall! –  Michael Hampton Oct 10 '13 at 0:57
    
@MichaelHampton ~ Sorry but I am newbie in this and I cant follow you! can you please add some details about what I am doing (thinking) wrong? –  safaali Oct 10 '13 at 1:02
add comment

2 Answers 2

up vote 3 down vote accepted

Your firewall is not the problem here, something in your code must be (and thus, this is not the right site to ask on).

What you're doing is allowing incoming connections to your server on port 465 though your server's firewall. The problem is that when you go to connect to gmail, you're connecting to port 465 on their servers. Port 465 on your server has nothing to do with this. There is nothing in that activity that establishes an inbound connection on port 465 on your server.

You're barking up the wrong tree, opening these ports isn't going to solve your problem.

share|improve this answer
    
Thank you for the explanation, I've checked the code, I am pretty sure it is ok. Is there any chance that another upper level firewall is blocking the outgoing trafic on port 465? I am on a VPS, surely the main server got a firewal. Should I check with the Hosting provider (main server administrator)? –  safaali Oct 10 '13 at 1:48
    
Sure there's a possibility, but it's not probably. I am unaware of any large hosts that filter outbound traffic. You can always ask your host, though. –  MDMarra Oct 10 '13 at 1:49
add comment

As seen in the output of your "netstat -tulpn" , you have RHEL distros, Exim smtp and Apache web server so you should check /var/log/messages file for more information about your problem with tailf -f command. If you are trying to send mail through PHP you should also check your httpd log file(/var/log/httpd/error_log or for vhosts check your httpd.conf file to find path under the VirtualHost scope)

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /www/docs/dummy-host.example.com
    ServerName dummy-host.example.com
    **ErrorLog logs/dummy-host.example.com-error_log**
    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
  1. As explained above posts it is not about incoming firewall rules. The problem may be in your outgoing firewall/iptables. Is this complete of iptables-save command output? Try

    iptables -L OUTPUT or iptables-save | grep OUTPUT

  2. Check your network interface and /etc/resolv.conf file.Your server may not resolve smtp.google.com. Try to ping smtp.google.com or other tools.

  3. Check your exim configuration and logs for more details. /var/log/exim_mainlog
share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.