本文整理匯總了Python中pykolab.imap.IMAP.parse_mailfolder方法的典型用法代碼示例。如果您正苦於以下問題:Python IMAP.parse_mailfolder方法的具體用法?Python IMAP.parse_mailfolder怎麽用?Python IMAP.parse_mailfolder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pykolab.imap.IMAP
的用法示例。
在下文中一共展示了IMAP.parse_mailfolder方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: execute
# 需要導入模塊: from pykolab.imap import IMAP [as 別名]
# 或者: from pykolab.imap.IMAP import parse_mailfolder [as 別名]
def execute(*args, **kw):
"""
List deleted mailboxes
"""
imap = IMAP()
imap.connect()
auth = Auth()
auth.connect()
domains = auth.list_domains()
folders = []
for domain in list(set(domains.keys())):
folders.extend(imap.lm("DELETED/*@%s" % (domain)))
folders.extend(imap.lm("DELETED/*"))
print "Deleted folders:"
for folder in folders:
mbox_parts = imap.parse_mailfolder(folder)
if not conf.raw:
print "%s (Deleted at %s)" % (imap_utf7.decode(folder).encode('utf-8'), datetime.datetime.fromtimestamp(int(mbox_parts['hex_timestamp'], 16)))
else:
print "%s (Deleted at %s)" % (folder, datetime.datetime.fromtimestamp(int(mbox_parts['hex_timestamp'], 16)))
示例2: execute
# 需要導入模塊: from pykolab.imap import IMAP [as 別名]
# 或者: from pykolab.imap.IMAP import parse_mailfolder [as 別名]
def execute(*args, **kw):
"""
Transfer mailbox
"""
if len(conf.cli_args) > 1:
mailfolder = conf.cli_args.pop(0)
target_server = conf.cli_args.pop(0)
if len(conf.cli_args) > 0:
target_partition = conf.cli_args.pop(0)
imap = IMAP()
imap.connect()
mbox_parts = imap.parse_mailfolder(mailfolder)
if mbox_parts['domain'] == None:
domain = conf.get('kolab', 'primary_domain')
user_identifier = mbox_parts['path_parts'][1]
else:
domain = mbox_parts['domain']
user_identifier = "%[email protected]%s" % (mbox_parts['path_parts'][1], mbox_parts['domain'])
auth = Auth(domain=domain)
auth.connect()
user = auth.find_recipient(user_identifier)
source_server = imap.user_mailbox_server(mailfolder)
imap.connect(server=source_server)
imap.imap.xfer(mailfolder, target_server)
if not user == None and not len(user) < 1:
auth.set_entry_attributes(domain, user, {'mailhost': target_server})