IMAP parser for both client and server