[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

php feof fwrite

Posted on 2007-11-17
3
Medium Priority
?
828 Views
Last Modified: 2008-08-17
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
//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);

Open in new window

0
Comment
Question by:tonelm54
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 20

Expert Comment

by:steelseth12
ID: 20306083
$handle = fopen("c:\\test\\51.eml", 'a');
   
       fwrite($popOpen,"RETR 51\n");      
   
       while (!feof($popOpen))
          {
          $buffer .= fgets($popOpen, 4096);
         
          }
             
       fwrite($handle,$buffer);
   
       fclose($handle);
0
 

Author Comment

by:tonelm54
ID: 20307187
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!
0
 
LVL 20

Accepted Solution

by:
steelseth12 earned 2000 total points
ID: 20308298
If $popOpen above is a valid resource then the code shoud work just fine.
Can you post the rest of your code ?

Here is some example code i found that can be of help to you.

http://www.weberdev.com/get_example-4015.html

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question