示例#1
0
文件: pm.py 项目: henca887/wappy
 def _put_message_into_folder(self, folder, recipient, subject, text):
     header = MailHeader()
     header.folder = folder
     header.uid = self._next_uid(folder)
     header.subject = subject
     header.flags = ''
     header.timestamp = time()
     header.save()
     body = MailBody()
     body.header = header
     body.text = text
     body.save()
示例#2
0
文件: imap.py 项目: henca887/wappy
def parse_header(data):
    """Parses imap headers fetched with the imap all macro."""
    parsed = create_dict(parse_list(data[0].partition(' ')[2])[1])
    envelope = parsed['ENVELOPE']
    if len(envelope) == 10:
        header = MailHeader()
        header.subject = envelope[1]
        header.flags = ' '.join(parsed['FLAGS'])
        header.timestamp = time.mktime(
            time.strptime(parsed['INTERNALDATE'], '%d-%b-%Y %H:%M:%S +0000'))
        return header
    return None