This script provides a EXPIREMENTAL caching layer on top of IMAP, either for clients with poor caching, or to let multiple clients share a cache. This cache is still expiremental, use it at your own risk. It may in fact eat your data, or babies.

What it does

Currently (2010-02-07), the feature set includes listing folders, selecting folders, fetching messages, including a prefetch feature, and server notifications. Additionally, you can set flags, expunge messages, copy messages, and append messages, all in what I'm calling write-back mode. Basically, the proxy will return success for the command before receiving a response from the origin. This is fast, but not safe. All modification commands are issued by UID, so there should be little danger of accidental flagging of the wrong message.

What it doesn't do

Many things are missing currently. Primarily there is no write-through mode which would wait for a response from the origin on modifications. For write-back mode, responses from the origin are not checked. Folder management is not implemented. Origin polling is through NOOP (not IDLE), and is tied to receiving commands from the client. SSL certs on the origin are not verified.

Expiremental Status

This is very much still an expiremental project. While I am not aware of any avenues for data loss, it is certainly a possibility. Additionally, SSL certs aren't verified, so you are at risk of man in the middle attacks. I have not yet used this with my production mail server, so you might want to wait as well.

How to use

History and download

Questions/Comments

Send questions, comments, or patches to imap@enslaves.us

There are many ways to generate an ssl cert. I would do:

openssl genrsa 1024 > certs/server-key.pem
openssl req -new -x509 -sha1 -key certs/server-key.pem > certs/server-cert.pem
You might want to tweak the length of validity or something, but this should get you started