Exemplo n.º 1
0
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
Exemplo n.º 2
0
Arquivo: pm.py Projeto: 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()