本文整理汇总了Python中util.Util.flattenMessage方法的典型用法代码示例。如果您正苦于以下问题:Python Util.flattenMessage方法的具体用法?Python Util.flattenMessage怎么用?Python Util.flattenMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Util
的用法示例。
在下文中一共展示了Util.flattenMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: store
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import flattenMessage [as 别名]
def store(self):
# delete old message
self.imap.uid('store',self.uid,'+FLAGS','(\Deleted)')
self.imap.expunge()
# store message
if self.seen:
self.imap.append(self.mailbox,'(\Seen)','',Util.flattenMessage(self.mail))
else:
self.imap.append(self.mailbox,'(\\Seen)','',Util.flattenMessage(self.mail))
示例2: encrypt
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import flattenMessage [as 别名]
def encrypt(self, uid):
typ, data = self.M.uid('fetch', uid,'(RFC822)')
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))
示例3: _extractMIMEPayload
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import flattenMessage [as 别名]
def _extractMIMEPayload(self,mail):
# Email is non multipart
if type(mail.get_payload()) == types.StringType:
# duplicate content-type and charset
mimemail = MIMEBase(mail.get_content_maintype(),mail.get_content_subtype(),charset=mail.get_content_charset())
mimemail.set_payload(mail.get_payload())
# copy transfer encoding
if mail.has_key('Content-Transfer-Encoding'):
del mimemail['Content-Transfer-Encoding']
mimemail['Content-Transfer-Encoding'] = mail['Content-Transfer-Encoding']
# for a multipart email just add every sub message
else:
mimemail = MIMEMultipart("mixed")
for payload in mail.get_payload():
mimemail.attach(payload)
return Util.flattenMessage(mimemail)