2014-06-06 315 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)。