2014-06-06 322 views
0

我试图连接到通过imaplib我的邮件服务器,并得到了在构造函数中的错误: 我的代码:蟒蛇2.7 imaplib错误

import imaplib 
imaplib.IMAP4_SSL('my_host.com', 1234) 

错误:

Traceback (most recent call last) 

/home/username/www/site/<ipython console> in <module>() 

/usr/lib/python2.7/imaplib.py in __init__(self, host, port, keyfile, certfile) 
    1163    self.keyfile = keyfile 
    1164    self.certfile = certfile 
-> 1165    IMAP4.__init__(self, host, port) 
    1166 
    1167 

/usr/lib/python2.7/imaplib.py in __init__(self, host, port) 
    197    self.state = 'NONAUTH' 
    198   else: 
--> 199    raise self.error(self.welcome) 
    200 
    201   typ, dat = self.capability() 

error: None 

的Python收到来自服务器的响应和然后提出错误,但这是正常的延续响应。从服务器 响应:

+OK my_host.com POP3 MDaemon 12.5.6 ready <[email protected]_host.com> 

我应该怎么做,从我的服务器收到我的邮件?

回答

2

恶魔点他使用协议POP3。你正在尝试使用IMAP协议来交流他。将lib更改为poplib或更改端口以通过IMAP协议进行通信(默认值为143)。