You are here: Re: IMAP PHP - Reading contents of 200+ emails « PHP Programming Language « IT news, forums, messages
Re: IMAP PHP - Reading contents of 200+ emails

Posted by Richard on 07/03/07 22:54

<shmick30@gmail.com> wrote in message
news:1183418921.335848.66310@o11g2000prd.googlegroups.com...
> 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:
>
> 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";
>

Hi NoName,

I would open the connection, read all needed info, close the connection and
only then do the processing.

Other things:
How long does the script take if you only read headers and nothing else?
(Try to simplify the script to narrow down the problem)
Why are you reading the message body twice? (First the full body, and then
the first body section?)
How big are the messages?
This is not the real script, is it? (Or is there some reason you do only 10
messages that I dont see?)

Richard.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация