Created
October 23, 2015 07:30
-
-
Save tolbrino/b72282188aaee1777b47 to your computer and use it in GitHub Desktop.
Script to check access of multiple email accounts against an IMAP host.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import sys | |
| import imaplib | |
| EMAIL_ACCOUNT_SUFFIX = "@mydomain.com" | |
| EMAIL_HOST = "mail.myhost.com" | |
| EMAIL_ACCOUNTS = { | |
| "name": "pass", | |
| } | |
| for name, pw in EMAIL_ACCOUNTS.items(): | |
| print("CONNECT") | |
| M = imaplib.IMAP4_SSL(EMAIL_HOST) | |
| try: | |
| account = name + EMAIL_ACCOUNT_SUFFIX | |
| print("LOGIN " + account) | |
| rv, data = M.login(account, pw) | |
| except imaplib.IMAP4.error: | |
| print ("LOGIN FAILED!!! ") | |
| continue | |
| print(rv, data) | |
| rv, mailboxes = M.list() | |
| if rv == 'OK': | |
| print("Mailboxes:") | |
| print(mailboxes) | |
| M.logout() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment