I'm not aware of any *server side* implementation of the IMAP protocol
other than that in twisted [and be prepared for typically terrible
twisted documentation].
<
https://github.com/davglass/twimapd>
On the other hand the basic of the IMAP protocol is pretty
straight-forward, client libraries implementations could be 'turned
around' pretty easily - you probably don't really need the *full* IMAP
suite for this application. One nice part about IMAP is that the server
reports a capabilities string - so it informs the clients that
extensions [possibly none] that it supports.