首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python/exchangelib -无法建立连接

Python/exchangelib -无法建立连接
EN

Stack Overflow用户
提问于 2017-06-27 00:14:37
回答 1查看 3.9K关注 0票数 1

很抱歉我的英语不太好:在windows域中,我尝试使用pypi站点上给出的示例连接到我们的exchangeserver (2010/SP3):

代码语言:javascript
复制
from exchangelib import DELEGATE, NTLM, Account, Credentials, Configuration
import os, logging

logging.basicConfig(level=logging.DEBUG)

creds = Credentials(
    username='mydomain\\my.name', 
    password='mypassword')

config = Configuration(server='exchange.xxx.local/EWS/Exchange.asmx', credentials=creds)

account = Account(
    primary_smtp_address='my.name@mycompany.com',
    credentials=creds,
    autodiscover=False,
    access_type=DELEGATE)

for item in account.inbox.all().order_by('-datetime_received')[:30]:
    print(item.subject, item.body, item.attachments)

启动脚本后,我在python控制台中得到以下输出:

代码语言:javascript
复制
DEBUG:exchangelib.protocol:Waiting for _protocol_cache_lock
DEBUG:exchangelib.protocol:Protocol __call__ cache miss. Adding key '('https://exchange.xxx.local/EWS/Exchange.asmx', Credentials('mydomain\\my.name', '********'), True)'
DEBUG:exchangelib.transport:Getting service auth type for https://exchange.xxx.local/EWS/Exchange.asmx
DEBUG:exchangelib.transport:Requesting b'<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"><s:Header><t:RequestServerVersion Version="Exchange2016" /></s:Header><s:Body><m:ResolveNames ReturnFullContactData="false"><m:UnresolvedEntry>mydomain\\my.name</m:UnresolvedEntry></m:ResolveNames></s:Body></s:Envelope>' from https://exchange.xxx.local/EWS/Exchange.asmx
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): exchange.xxx.local
Traceback (most recent call last):
  File "C:\CWS\Python-venv\p353-01\lib\site-packages\urllib3\connectionpool.py", line 594, in urlopen
self._prepare_proxy(conn)
  File "C:\CWS\Python-venv\p353-01\lib\site-packages\urllib3\connectionpool.py", line 810, in _prepare_proxy
conn.connect()
  File "C:\CWS\Python-venv\p353-01\lib\site-packages\urllib3\connection.py", line 294, in connect
self._tunnel()
  File "C:\seProg\python353\Lib\http\client.py", line 832, in _tunnel
message.strip()))
OSError: Tunnel connection failed: 407 Proxy Access Denied    
... (and many more lines with error messages)

我还尝试了exchangelib站点上的其他选项,使用autodiscover=True,只给出了creds= (不使用config=)。没有成功。然后,我从https://ewseditor.codeplex.com/安装了EWS-Editor,以便查看通过EWS的连接是否可以在我公司的环境中工作。它与该工具一起工作得很好,只需给它我的SMTP地址。

我将非常感谢任何人的帮助。提前感谢!

EN

回答 1

Stack Overflow用户

发布于 2017-07-11 05:33:57

你可能需要告诉exchangelib关于你的代理。您可以通过环境变量:https://github.com/ecederstrand/exchangelib/issues/123#issuecomment-295648189或自定义HTTPAdapter类:https://github.com/ecederstrand/exchangelib/issues/156#issuecomment-312391095来执行此操作

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44764071

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档