php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1667 fsockopen still doesn't seem to work
Submitted: 1999-07-06 04:10 UTC Modified: 1999-07-10 16:58 UTC
From: joop dot vriend at ddnh dot nl Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.11 OS: Linux 2.1
Private report: No CVE-ID: None
 [1999-07-06 04:10 UTC] joop dot vriend at ddnh dot nl
The fsockopen function still doesn't seem to work for us in version 3.0.11, although code we downloaded from the CVS tree just after version 3.0.8 did the job OK.

This is a piece of code we use for sending mail. When we try to execute it, it just stalls forever.

$FM_fp = fsockopen($FM_mailserver, 25);
if ($FM_fp) {
	$FM_s	= 0;
	$FM_c	= 0;
	$FM_out	= "";
	set_socket_blocking($FM_fp, false);
	do {
		$out = fgets($FM_fp, 2500);
		if (ereg( "^220", $out)) {
			$FM_s	= 0;
			$FM_out	= "";
			$FM_c++;
		} else if (( $FM_c > 0 ) && ( $FM_out == "" )){
			break;
		} else {
			$FM_s++;
		}
		if ($FM_s == 9999) break;
	} while ($FM_out == "");
	set_socket_blocking($FM_fp, true);

	fputs ($FM_fp, "HELO ddnh.nl\n");
	$FM_output = fgets($FM_fp, 2000);
	fputs ($FM_fp, "MAIL FROM: <sender>\n");
	$FM_output = fgets($FM_fp, 2000);
	fputs ($FM_fp, "RCPT TO: <$to_email>\n");
	$FM_output = fgets($FM_fp, 2000);
	if (!ereg("^250", $FM_output)) {
		fputs ($FM_fp, "QUIT\n");
		fclose($FM_fp);
		Error(5, $mailto);
	}

	fputs ($FM_fp, "DATA\n");
	$FM_output = fgets($FM_fp, 2000);

	/** Mail headers **/
	fputs ($FM_fp, "Subject: $titel\n");
	fputs ($FM_fp, "From: $from_name <$from_email>\n");
	fputs ($FM_fp, "Reply-To: $to_email\n");
	fputs ($FM_fp, "To: $to_email\n");
	fputs ($FM_fp, "\n");

	/** Message **/
	fputs ($FM_fp, "...message...\n");
	fputs ($FM_fp, ".\n");
	$FM_output = fgets($FM_fp, 2000);

	fputs ($FM_fp, "QUIT\n");
	fclose($FM_fp);
}

This is our configure line:
./configure --with-apache=/usr/src/apache --with-gd=/usr/src/gd --with-oracle=/u01/app/oracle/product/8.0.5 --with-pgsql --with-config-file-path=/usr/local/apache/conf --enable-debug=no --enable-track-vars=yes --enable-magic-quotes=yes

I hope this is of any use for you and that the problem will be solved quickly.

Joop Vriend.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-07-06 10:04 UTC] sas at cvs dot php dot net
If you want us to solve it quickly, we need more information. What does it do what it's not expected to do? Where does it stall?
 [1999-07-10 13:07 UTC] sas at cvs dot php dot net
Recompile and let us know whether it works now:

$ cd php-3.0.11/functions
$ wget -O fsock.c http://cvs.php.net/cvsweb.cgi/functions/fsock.c?rev=1.124
 [1999-07-10 16:58 UTC] sas at cvs dot php dot net
fixed in CVS
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 13 20:01:31 2024 UTC