ID: 22947 Comment by: lwillis at plus dot net Reported By: me at mattbeale dot plus dot com Status: Assigned Bug Type: Mail related Operating System: Windows 2000 SP4 PHP Version: 4CVS-2003-04-29 (stable) Assigned To: edink New Comment:
As far as I can see from section 4.1.1.1 of RFC 2821 the response given to the HELO command is perfectly valid. http://www.faqs.org/rfcs/rfc2821.html The check for a space and then dash was introduced into win32/sendmail.c at version 1.20 with the following log entry: -------------------------------------- revision 1.20 date: 2000/09/05 00:26:15; author: sterling; state: Exp; lines: +5 -2 This should fix the multiple-line problem. -------------------------------------- Not sure which "multiple line problem" though - possibly bug 6537 Either way, the response we're sending looks like it should be handled fine by PHP - and it certainly shouldn't cause a hang (I expect PHP is waiting for more data trying to get the next line of a multi-line response - but it should be doing this as the response code (250) is followed by a space, not a dash ... Previous Comments: ------------------------------------------------------------------------ [2003-08-03 09:05:38] me at mattbeale dot plus dot com Does this not get acknowledgement unless the Status is set back to Open? ------------------------------------------------------------------------ [2003-08-02 18:28:51] phpbugs at pligplob dot com This does seem to be a fault in the Windows code, the Ack() function in sendmail.c: win32/sendmail.c(Ack): ... if ((buf[Received - 4] == ' ' && buf[Received - 3] == '-') || ... It is specifically disallowing SPACE HYPHEN at the end of the SMTP reply text that PlusNet's server is sending, but that seems to be allowed by RFC2821. However, since someone has deliberately blocked this pattern there must be a reason for it, but it seems invalid to me. When I modifed the php4ts.dll to use EHLO instead of HELO the SMTP exchange completed successfully. PlusNet's server avoids the "illegal" SPACE HYPHEN in its extended reply, so the hangup doesn't occur. ------------------------------------------------------------------------ [2003-07-30 15:39:46] me at mattbeale dot plus dot com In addition to my previous message: This PHP code works fine on both machines that have problems. I doubt I need to tell you what it does?: <?php function bytesleft($fp) { $status = socket_get_status($fp); $bytes = $status['unread_bytes']; return $bytes; } function sendtext($str) { global $fp; echo $str; flush(); fwrite($fp, $str); $ret = fread($fp, 1); $ret.= fread($fp, bytesleft($fp)); return $ret; } $fp = false; if ($fp = fsockopen('relay.plus.net', 25, $errno, $errstr, 1)) { socket_set_timeout($fp, 1); $hash = md5(uniqid(rand())); echo sendtext("HELO server\r\n"); echo sendtext("MAIL FROM: [EMAIL PROTECTED]"); echo sendtext("RCPT TO: [EMAIL PROTECTED]"); echo sendtext("DATA\r\n"); echo sendtext("From: Matt Beale <[EMAIL PROTECTED]>\r\n"); echo sendtext("Subject: [PHP] Test Subject - {$hash}\r\n"); echo sendtext("To: Matt Beale <[EMAIL PROTECTED]>\r\n"); echo sendtext("\r\n"); echo sendtext("This is a test message sent from PHP\r\n"); echo sendtext("\r\n"); echo sendtext("Hash: {$hash}\r\n"); echo sendtext(".\r\n"); echo sendtext("QUIT\r\n"); fclose($fp); } ?> If Andrew happens to read this, I'd be interested to know if it works for him. Plus I'd be very interested in what the PHP developers think might be going on. ------------------------------------------------------------------------ [2003-07-30 07:54:51] me at mattbeale dot plus dot com I wouldn't know what else to try and eliminate. I've tried two operating systems with different service packs and two methods of Internet Connection (Router and USB Modem). The only thing I can't change is my ISP. I can only conclude that there must be something 'up' with my ISPs mail server, but if that is the case why do I only get problems with PHP? Everything else works fine - I can send mail from Outlook/Outlook Express/Mozilla fine and I also use POPFile 0.19.1 on my server which has no problems with communicating with my ISPs mail server. If there were really problems with my ISPs mail server, wouldn't I experience similar problems in the other applications I use? ------------------------------------------------------------------------ [2003-07-30 02:05:33] [EMAIL PROTECTED] I can't reproduce this either, must be local problem to you only. (we'd have hundreds of reports about this if it really was a bug) ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/22947 -- Edit this bug report at http://bugs.php.net/?id=22947&edit=1