Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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))