Python 2.7 imaplib错误

0 投票
1 回答
693 浏览
提问于 2025-04-18 08:50

我尝试通过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 <MDAEMON-F201406061147.AA472534MD1387@my_host.com>

我该怎么做才能从我的服务器接收邮件呢?

1 个回答

2

这个人使用的是POP3协议,而你想用IMAP协议和他交流。你可以把库换成poplib,或者把端口改成IMAP协议的端口(默认是143)。

撰写回答