php-imap
php-imap copied to clipboard
Execution time for retrieval a message
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);
Is that a problem you noticed? Is there a way to solve this problem?
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,