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

Very slow message loading its about 2 to 3 min for getting 10 messages using pagination on GMAIL INBOX folder.

Open cms007 opened this issue 4 years ago • 3 comments

Describe the bug Folder listing is very fast but as soon as it starts to fetch messages it is very slow.

Code to Reproduce

$cm = new ClientManager($options = []);

$emailClient = $cm->make([
    'host'  => $emailSetting->incoming_server_host,
    'port' => $emailSetting->incoming_server_port,
    'encryption' => 'ssl',
    'validate_cert' => true,
    'username' => $emailSetting->username, /// THIS IS GMAIL ACCOUNT
    'password' => $emailSetting->password,
    'protocol' => $emailSetting->protocol,
]);

$emailClient->connect();

$emailClient->getFolders(); // THIS IS SUPER QUICK

// THIS IS SUPER SLOW
$messages = $emailFolder->query()
                        ->setFetchBody(false)
                        ->all()
                        ->fetchOrderDesc()
                        ->paginate($per_page = 10, $page = 1, $page_name = 'imap_page');

cms007 avatar Oct 16 '21 13:10 cms007

@Webklex - Anything here?

cms007 avatar Oct 24 '21 03:10 cms007

Hi @cms007 , many thanks for your report. I personally can't replicate this behavior. Do you experience the same if you are using a different account and / or provider? Is it the same, if you fetch messages from a different folder / inbox? How does it behave if you perform the same calls as above but from a different host?

Best regards,

Webklex avatar Oct 25 '21 14:10 Webklex

Hi @cms007 , please give the current master a try. Also make sure you've enabled options.debug. This might help to figure out which part in the communication takes so long.

Best regards,

Webklex avatar Nov 03 '21 18:11 Webklex