I'm currently working on a project where i need to fetch all emails of an employee by using PHP IMAP. For this I'm using following library..
PHP IMAP Library : https://github.com/barbushin/php-imap
This library is working pretty well. But, I'm facing a lot of latency in fetching emails from mail server(currently using Gmail). It's taking around 7/8 secs on an avg for each request & sometimes it's more than this also.
Currently, I'm using search(imap_search) criteria as 'ALL' first to get all emails id first. Then I'm selecting 5 ids from this list & fetching all email message one by one. This is the process i'm following to show all email message by using a pagination.
Folks, need some suggestion regarding whole process.. so that, it'll decrease the latency & improve the email fetching speed.