First (not finished) version of imap plugin