It proxies IMAP transactions Between an IMAP client and an IMAP server. The general idea is that the client should never know that it's not talking to the real IMAP server. The only thing that makes this a slightly unique Imap Proxy server is that it caches server connections.
Why was imapproxy written in the first place?
imapproxy was written to compensate for webmail clients that are unable to maintain persistent connections to an IMAP server. Most webmail clients need to log in to an IMAP server for nearly every single Transaction. This behaviour can cause tragic performance problems on the IMAP server. imapproxy tries to deal with this problem by leaving server connections open for a short time after a webmail client logs out. When the webmail client connects again, imapproxy will determine if there's a cached connection available and reuse it if possible.
How does imapproxy keep track of which server connection is for which user?
Upon the first successful login to the real IMAP server (through the proxy), imapproxy fills in a Little record that contains the username, an md5 digital signature of the password and the server socket descriptor that's being used. After you log out and then log back in again, imapproxy just has to find a record that matches your username and password. These records are stored in a hash table (with the username being the hash key) in memory, so the lookups are pretty fast.