我有以下代码连接到Microsoft Exchange服务器(2010版) . 这是我遇到麻烦的剪辑 . (它适用于其他电子邮件服务器/本地邮件服务器进行测试) . 用户/密码经过验证,为此目的,硬编码,因此不会错过拼写问题 . 我在microsoft outlook中使用此电子邮件帐户,因此它在服务器端也是有效的 .
self.connection = poplib.POP3_SSL('my.email.server')
self.connection.set_debuglevel(2)
print self.connection.getwelcome()
self.connection.user('myuser')
self.connection.pass_('mypassword')
结果如下:
+OK The Microsoft Exchange POP3 service is ready.
*cmd* 'USER myuser'
*put* 'USER myuser'
*get* '+OK\r\n'
*resp* '+OK'
*cmd* 'PASS mypassword'
*put* 'PASS mypassword'
*get* '-ERR Logon failure: unknown user name or bad password.\r\n'
*resp* '-ERR Logon failure: unknown user name or bad password.'
Traceback (most recent call last):
File "getMail.py", line 237, in <module>
start_deamon()
File "getMail.py", line 229, in start_deamon
deamon.process_email()
File "getMail.py", line 63, in process_email
self.connection.pass_('password')
File "C:\Python27\lib\poplib.py", line 189, in pass_
return self._shortcmd('PASS %s' % pswd)
File "C:\Python27\lib\poplib.py", line 152, in _shortcmd
return self._getresp()
File "C:\Python27\lib\poplib.py", line 128, in _getresp
raise error_proto(resp)
poplib.error_proto: -ERR Logon failure: unknown user name or bad password.
错误是非常明显的,但我确信用户/通行证是真的,我试图通过POP和POP_SSL连接结果是一样的 . 我收到欢迎消息,所以我知道服务器是UP并支持POP3 / POP3_SSL并且端口是正确的(这是默认的) . 我不在服务器在同一网络上的任何防火墙/代理后面 .
可能是什么错误?有没有其他方法只使用POP3连接到Microsoft Exchange? (或者如果需要IPMA) .
1 回答
看起来错误它不是程序化的 . POP3和POP3_SSL代码本身也没问题 .
问题实际上是在未在网络上进行身份验证的计算机上运行代码,因此Exchange服务器从不允许登录 .