summaryrefslogtreecommitdiff
path: root/py-fake-service/app/adapter/mail_service.py
blob: b657e59ae79f3263a1a9cbe6c23e4b53c378bfae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import os
import mailbox


class MailService:
    MAILSET_PATH = os.join(os.environ('HOME'), 'mailset', 'mediumtagged'))

    def __init__(self):
        self.mails = MailSet()

    def load_mailset(self):
        mbox_filenames = [filename for filename in os.listdir(MAILSET_PATH) if mbox.startswith('mbox')]
        boxes = (mailbox.mbox(os.path.join(MAILSET_PATH, mbox)) for mbox in mbox_filenames) 

        for box in boxes:
            message = box.popitem()
            self.mails.add(message[1])