Test connection IMAP on python
#!/usr/bin/python
import imaplib
imap_server = "mail.domain.com"
username = "domain.com\usernname" ## Exchange login format
mail_pass = "password"
imap = imaplib.IMAP4_SSL(imap_server)
print(imap.login(username, mail_pass))
print(imap.select("INBOX"))
print(imap.search(None, 'ALL'))