updated to work with latest imap module api