开始报的这个:
command SEARCH illegal in state AUTH, only allowed in states SELECTED
死活找不到原因,Traceback里提示:
File "/usr/lib/python3.5/imaplib.py", line 863, in uid
', '.join(Commands[command])))
于是打开imaplib.py找SELECTED,在731行找到:
self.state = 'AUTH' # Might have been 'SELECTED'
在上面的729行找到:
typ, dat = self._simple_command(name, mailbox)
于是print(dat),这才看到:
The login is not safe! Please update your mail client: http://mail.163.com/dashi
为了推自己的客户端
好了,是163在做怪,错怪imbox了,google一下找到:
http://stackoverflow.com/questions/27797705/python-login-163-mail-server
解决方案是通过下面的地址,配置一下即可:
http://config.mail.163.com/settings/imap/index.jsp?uid=YOUR_EMAIL_NAME@126.com
当然还看到这个方法,在命令前加C:
http://billynyh.github.io/blog/2015/05/16/javamail-163/

本文记录了解决使用Python访问163邮箱时遇到的IMAP认证错误过程。错误信息显示为:command SEARCH illegal in state AUTH,仅允许在SELECTED状态下执行。通过排查发现163邮箱服务器要求进行特定设置以启用安全登录。
2359

被折叠的 条评论
为什么被折叠?



