Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function.fsockopen]: unable to connect to localhost:25

Status
Not open for further replies.

Phara0h

Programmer
Aug 1, 2004
18
0
0
NO
I am having problems connecting to ports from my php code.

This has worked for a couple of years.

I am on my own server, and have root ssh access.

I can telnet to my localhost 25 with no problem from ssh.

--

box1:~ # telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 box1.siteman.no ESMTP Postfix

--

I use this as a testscript on php:

<?php
$fp = fsockopen("localhost", 25, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: $out .= "Connection: Close\r\n\r\n";

fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>

--

I get this error on the testpage:

Warning: fsockopen() [function.fsockopen]: unable to connect to localhost:25 in / on line 2
Connection timed out (110)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top