本文整理汇总了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})