I have a simple php script on a server that’s using fsockopen to connect to a server.
<?php $fp = fsockopen('smtp.gmail.com', 25, $errno, $errstr, 30); if (!$fp) { echo '$errstr ($errno)<br />\n'; } else { echo fgets($fp, 1024); fclose($fp); } ?>
The problem is the the script times out and fails to connect. If i change the port from 25 to 80 for example it works without problems on any host. So the problem seems to be only the port 25 no matter what host i use, i tried a lot of them and all work for port 80 and others but for 25 fails.
Connections are not blocked form firewall as if i telnet from shell it successfully connects to any port on any host.
Any idea what could be the problem as it’s really weird?
LE: If i run the same php script from the shell, php scriptname.php it works so only when i run it by http it fails. I have apache with SuPHP so the problem is around here somewhere
Interesting… Some firewalls can block specific program’s connections to specific ports. Please check it again, try to stop firewall completely. Also try to stop any anti-spyware.