tonelm54
asked on
php feof fwrite
I have written some code, which collects emails through a pop3 server, Got it working, however fails to read big emails.
From what Ive read I need to use a while loop, but when I read just 1 email, I get timeout error. In my working example takes milliseconds to pull the email, and about 3 seconds to collect 110 emails.
Do I need to tell it to go to the next line and read?
Tony
From what Ive read I need to use a while loop, but when I read just 1 email, I get timeout error. In my working example takes milliseconds to pull the email, and about 3 seconds to collect 110 emails.
Do I need to tell it to go to the next line and read?
Tony
//Very Slow!!!
$handle = fopen("c:\\test\\51.eml", 'a');
fwrite($popOpen,"RETR 51\n");
while (!feof($popOpen))
{
$buffer = fgets($popOpen, 4096);
fwrite($handle,fread($popOpen,8192));
}
fclose($handle);
//Works
$handle = fopen("c:\\test\\51.eml" . $counter . ".eml", 'a');
fwrite($popOpen,"RETR " . $counter . "\n");
fwrite($handle,fread($popOpen,8192));
fclose($handle);
ASKER
Nope still the same problem.
During debug it seems to enter the while loop, go round several times, then stop, and just hang!
I would suggest that it isnt able to see the last 4096 and maybe less, but as I dont know too much about this, cant really suggest it.
HELP!!! I dont have much hair left, lol!
During debug it seems to enter the while loop, go round several times, then stop, and just hang!
I would suggest that it isnt able to see the last 4096 and maybe less, but as I dont know too much about this, cant really suggest it.
HELP!!! I dont have much hair left, lol!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
fwrite($popOpen,"RETR 51\n");
while (!feof($popOpen))
{
$buffer .= fgets($popOpen, 4096);
}
fwrite($handle,$buffer);
fclose($handle);