Implemented some preliminary IMAP support (don't expect it to work yet!)