From 51129fda2179286143921db55a69b3f4dba03c0e Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sun, 25 Oct 2015 19:42:14 -0700 Subject: Adding Canary Check and Accounts Adding the canary check method and tests for the Canary class. Adding accounts to CanaryDB. --- emailcanary/emailutils.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'emailcanary/emailutils.py') 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() -- cgit v1.2.3