|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-08-31 18:37 UTC] donald at designknights dot com
[2007-10-22 11:28 UTC] jani@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 03:00:01 2025 UTC |
Description: ------------ this is a script to connect to a pop3 server and parse emails. $connection = fsockopen($popServer, $port, $error ,$string ,$timeout); $response = fgets($connection, $buffer); $newLine = "\r\n"; $localhost = "www.designknights.com"; if(empty($connection)) { echo "Failed to connect: $response"; exit; } else { $logArray['connection'] = "Connected to: $response"; } echo "sending username<br>"; ob_flush(); flush(); fputs($connection, "USER $username". $newLine); $response = fgets($connection, $buffer); $logArray['userresponse'] = "$response"; fputs($connection, "PASS $password". $newLine); $response = fgets($connection, $buffer); $logArray['passresponse'] = "$response"; if (substr($response,0,3)!="+OK"){ echo "Mail server said: ".$response; exit; } fputs($connection,"LIST".$newLine); $msg_array = array(); $response = fgets($connection,$buffer); $logArray['listresponse'] = "$response"; $messages = explode(" ",$response); $nummessages = $messages['1']; echo "number of messages =".$nummessages; stream_set_blocking($connection,1); for ($i=1;$i<=$nummessages;$i++){ fputs($connection,"retr ".$i.$newLine,$buffer); $message = ''; $line = ''; //This loop is where it hangs while (!feof($connection){ $line = fgets($connection,$buffer); echo "<br> line = $line"; ob_flush(); flush(); } $message_blown = explode(":",$message); echo "<br> message $i = <br>"; print_r($message_blown); } echo "return = ".print_r($messages)."<br>"; print_r($logArray); fclose($connection); Reproduce code: --------------- See above Expected result: ---------------- It should to my understanding put the lines into the var names $message then explode that message into $message_blown using : as a separator. Actual result: -------------- it hangs and the max execution time kills php5 while running the script.