Skip to content

Commit 727f90d

Browse files
author
vinod (mercury)
committed
search mailboxes
1 parent 6da9126 commit 727f90d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pygmail.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def login (self, username, password):
1111
self.M = imaplib.IMAP4_SSL(self.IMAP_SERVER, self.IMAP_PORT)
1212
status, message = self.M.login(username, password)
1313

14-
def get_mailbox_list(self):
14+
def get_mailboxes(self):
1515
status, folders = self.M.list()
1616
return folders
1717

@@ -31,3 +31,14 @@ def get_imap_quota(self):
3131
r.append(0)
3232
r.append(0)
3333
return float(r[1])/1024, float(r[0])/1024
34+
35+
def get_mails_from(self, uid, folder='Inbox'):
36+
status, count = self.M.select(folder, readonly=1)
37+
status, response = self.M.search(None, 'FROM', uid)
38+
email_ids = [e_id for e_id in response[0].split()]
39+
return email_ids
40+
41+
def get_mail_from_id(self, id):
42+
status, response = self.M.fetch(id, '(body[header.fields (subject)])')
43+
return response
44+

0 commit comments

Comments
 (0)