0 votes

I want to login using my Imap credentials once and keep the connection persistent.
I am trying to create an email client application. I want a connection that persists so that I don't have to login for each action I have to perform in Imap server.(By 'each action' I mean - select folder, then get email data, then flag as seen, then move to trash all by one persistent Imap connection)

How do Email clients like hotmail, gmail and yahoo keep connection persistent?

Thanks.

by (1.2k points)

1 Answer

0 votes

I can only speculate how gmail/hotmail internally work internally.

I would expect most write operations are cached and performed in bulks on the background service rsuting in immediate cache updates only.

Similar for read operations: in most cases you can expect what user is going to do and pre-load them.

For example logging-in most likely results in several IMAP operations: logging in, getting all folders with counts, selecting INBOX and retrieving most common details for the last 50 messages. If there are unread emails those will probably be accessed and can be pre-fetched. I would expect all those details are cached.

IMAP connection is persisted on the background service, not inside the web application.

Technically as long as you don't close and dispose Imap instance the connection is maintained. You can use Noop method to make sure that it is used and is not cut by the server or any of the intermediate routers.

by (298k points)
...