How to use the imaplib2.Time2Internaldate function in imaplib2

To help you get started, we’ve selected a few imaplib2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mannkind / imap_encrypt / IMAPEncrypt.py View on Github external
if data == None:
            return

        mail = email.message_from_string(data[0][1])
        if mail.get_content_type() == 'multipart/encrypted':
            return

        # Parse the original date
        headerFields = email.parser.HeaderParser().parsestr(data[0][1])
        if headerFields == None: 
            date = ''
        else:
            pz = email.utils.parsedate_tz(headerFields['Date'])
            stamp = email.utils.mktime_tz(pz)
            date = imaplib2.Time2Internaldate(stamp)

        # Encrypt the message
        encrypted_mail = gpg.GPGEncryption().encryptPGP(mail, self.config['pubkey'])
    
        # Delete the plaintext message
        if 'trash' in self.config and self.config['trash'] != '':
            self.M.uid('copy', uid, self.config['trash'])
    
        self.M.uid('store', uid, '+FLAGS', '\\Deleted')
        self.M.expunge()
        
        # Append the encrypted message
        move_to = self.config['mailbox'] if 'move_to' not in self.config else self.config['move_to']
        read = '' if self.config['monitor'] == 'UNSEEN' else '\\seen'
        self.M.append(move_to, read, date, Util.flattenMessage(encrypted_mail))

imaplib2

A threaded Python IMAP4 client.

MIT
Latest version published 3 years ago

Package Health Score

63 / 100
Full package analysis

Similar packages