Suresh
Suresh

Reputation: 5987

How improve email fetching by PHP IMAP

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.

Upvotes: 3

Views: 524

Answers (1)

Andrew Turnbull
Andrew Turnbull

Reputation: 33

I had the same issue but with PHPMailer. The solution for me was to just put all the operations into a queue and run them on a schedule.

Unless you need the emails upon request by the user, a queue would be the best option.

Upvotes: 0

Related Questions