|  | Posted by Benjamin on 07/03/07 01:43 
On Jul 2, 6:28 pm, shmic...@gmail.com wrote:> Hi There,
 >
 > I am looping through and reading the body contents of a mail box with
 > over 200 emails in it. The script is running very slow and timing out
 > after 180 seconds, only getting through about 180 of these emails. Is
 > there anyway I can increase the speed of this script? Why is it taking
 > so long to loop through all these emails? Code is below:
 Probably most of the delay is network latency. How fast is your
 connection?
 >
 > if($mailbox= imap_open( "{###.###.#.###:143/imap}mail_box", $a, $b))
 > {
 >         set_time_limit(180);
 >         $check = imap_check($mailbox);
 >         $message_count = imap_num_msg($mailbox);
 >
 >         for ($i=1;$i<=10;$i++)
 >         {
 >
 >                 $header = imap_header($mailbox,$i);
 >                 $body = imap_body($mailbox,$i);
 >                 $message = imap_fetchbody($mailbox,$i,1);
 >
 >                 $strpos = strripos($message,"textfield3");
 >                 $prettydate = date("jS F Y", $header->udate);
 >
 >                 echo $prettydate." - ".substr($message, $strpos+13, 8)."<br/>";
 >
 >         }
 >
 >          imap_close($mailbox);}
 >
 > else echo "no connection";
  Navigation: [Reply to this message] |