diff options
| author | Jesse Morgan <jesse@jesterpm.net> | 2015-10-25 19:42:14 -0700 |
|---|---|---|
| committer | Jesse Morgan <jesse@jesterpm.net> | 2015-10-25 19:42:14 -0700 |
| commit | 51129fda2179286143921db55a69b3f4dba03c0e (patch) | |
| tree | f09690727e5000af8e9e7bd9359fe37c81210fcd /emailcanary/emailutils.py | |
| parent | 5319d2f0f013a340cb0fdc396bbe4f0ae8df5142 (diff) | |
Adding Canary Check and Accounts
Adding the canary check method and tests for the Canary class.
Adding accounts to CanaryDB.
Diffstat (limited to 'emailcanary/emailutils.py')
| -rw-r--r-- | emailcanary/emailutils.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/emailcanary/emailutils.py b/emailcanary/emailutils.py index 6646c1e..b87f637 100644 --- a/emailcanary/emailutils.py +++ b/emailcanary/emailutils.py @@ -1,9 +1,9 @@ import imaplib, email -def get_imap(account): +def get_imap(server, username, password): '''Connect and login via IMAP''' - mail = imaplib.IMAP4_SSL(account[0]) - mail.login(account[1], account[2]) + mail = imaplib.IMAP4_SSL(server) + mail.login(username, password) return mail def get_mail_uids(mail): @@ -16,4 +16,12 @@ def get_message(mail, uid): '''Get a single email message object by UID''' result, data = mail.uid('fetch', uid, '(RFC822)') raw_email = data[0][1] - return email.message_from_string(raw_email)
\ No newline at end of file + return email.message_from_string(raw_email) + +def delete_message(mail, uid): + result = mail.uid('store', uid, '+FLAGS', '\\Deleted') + +def close(mail): + mail.expunge() + mail.close() + mail.logout() |
