1

尝试使用以下代码阅读雅虎电子邮件。错误消息显示“注意:邮箱已被服务器从此处锁定到 'quit()'”

Q> 如何解决这个问题?

import poplib
from email import parser

pop_conn = poplib.POP3_SSL('pop.mail.yahoo.com')
pop_conn.user('xxxx@yahoo.com')
pop_conn.pass_('xxxx')

#Get messages from server:
iMessageCount = len(pop_conn.list()[1])
messages = [pop_conn.retr(i) for i in range(1, iMessageCount + 1)]


# Concat message pieces:
messages = ["\n".join(mssg[1]) for mssg in messages]

#Parse message intom an email object:
messages = [parser.Parser().parsestr(mssg) for mssg in messages]
for message in messages:
    print message['subject']


13 #Get messages from server:


/usr/lib/python2.7/poplib.pyc in pass_(self, pswd)
    187         NB: mailbox is locked by server from here to 'quit()'
    188         """
--> 189         return self._shortcmd('PASS %s' % pswd)
4

0 回答 0