title: php fsockopen
body: <p>I have a simple php script on a server that's using fsockopen to connect to a server.</p>
  
  <pre><code>&lt;?php
  $fp = fsockopen("smtp.gmail.com", 25, $errno, $errstr, 30);
  if (!$fp) {
      echo "$errstr ($errno)&lt;br /&gt;\n";
  } else {
      echo fgets($fp, 1024);
      fclose($fp);
  }
  ?&gt;
  </code></pre>
  
  <p>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.<br>
  Connections are not blocked form firewall as if i telnet from shell it successfully connects to any port on any host.<br>
  Any idea what could be the problem as it's really weird?   </p>
  
  <p>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</p>