php-imap icon indicating copy to clipboard operation
php-imap copied to clipboard

Execution time for retrieval a message

Open Frizzouille opened this issue 2 years ago • 1 comments

Good morning,

I have an application where I would like to retrieve my mails, but I noticed that the ->getMessageByMgsn() or ->getMessageByUid() function can take a long time to run with mails with attachments. The execution time is proportional to the size of the mail and so I have mails that can take more than 30 seconds.

Here is an example below, each item is a mail with its size first following recovery time.

$t1 = microtime(true); $executionTime = array(); for($i = $info['exists']; $i > $info['exists']-5 && $i > 0; $i--){ $message = $query->getMessageByMsgn($i); $t2 = microtime(true); $executionTime[$i] = array($message->getSize(), $t2 - $t1); $t1 = $t2; } var_dump($executionTime);

Capture d’écran 2023-06-22 084621

Is that a problem you noticed? Is there a way to solve this problem?

Frizzouille avatar Jun 22 '23 06:06 Frizzouille

Hi @frizzcarambar , many thanks for your report. I'm afraid there isn't much I can do about it - the mail server itself as well as your connection to the server are the bottlenecks. You could speed things up for sure, by working with the protocol directly. But requesting and fetching data still takes some time.

However, please feel free to prove me wrong. Pull requests are always welcome :)

Best regards & happy coding,

Webklex avatar Jun 28 '23 02:06 Webklex