使用soap 协议登录zimbra,并且获取收件箱信息

#!/usr/bin/env python
'''
目的:使用soap 协议登录zimbra,并且获取收件箱信息
参考链接:
	https://wiki.zimbra.com/wiki/Preauth
	https://github.com/Zimbra-Community/python-zimbra
请用python2.7 版本
pip install python-zimbra
'''
 from pythonzimbra.tools import auth
 from pythonzimbra.communication import Communication

url = 'https://10.10.61.131/service/soap'
comm = Communication(url)
#使用key认证
token = auth.authenticate(
    url,
    'zhailibao',
    '2fa99f699fd567f60149a04fc5ce05daecc0740dd06baeac0f5ae6d047'
)
 #使用用户名密码认证
#token = auth.authenticate(
#    url,
#    'zhailibao',
#    '123456',
#    use_password=True,
#)
info_request = comm.gen_request(token=token)
info_request.add_request(
    "GetFolderRequest",
    {
        "folder": {
            "path": "/inbox"
        }
    },
    "urn:zimbraMail"
)
info_response = comm.send_request(info_request)
 print info_response.get_response()
 if not info_response.is_fault():
         print info_response.get_response()['GetFolderResponse']['folder']['n']


你可能感兴趣的:(使用soap 协议登录zimbra,并且获取收件箱信息)