One difficulty I have with IMAP is that there is very little documentation for implementers to go by that I can find. I had to read a python imap library bug report in order to confirm my reading of RFC3501 whilst reverse engineering real responses from a gmail server.