python登录163邮件服务器 [英] python login 163 mail server

查看:103
本文介绍了python登录163邮件服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用此脚本登录163邮件服务器时,出了点问题!
我的python env是python 2.7.8
请帮助我!

When I use this script to login the 163 mail server,there is something wrong! My python env is python 2.7.8 Please help me!

import imaplib

def open_connect(verbose=False):
    host = 'imap.163.com'
    port = 993
    if verbose:print 'Connecting to',host
    connection = imaplib.IMAP4_SSL(host)
    username = 'tmailest@163.com'
    passwd = 'aaannnmmm'
    if verbose:print 'Logging in as',username
    try:
        connection.login(username,passwd)
    except Exception as err:
        print 'ERROR:', err

    return connection

c = open_connect()

try:
    tye,data = c.select('INBOX')
    print tye,data
    num_msgs=int(data[0])
    print 'There are %d messages in INBOX' % num_msgs
finally:
    c.close()
    c.logout()

====

NO ['SELECT The login is not safe! Please update your mail client: http://mail.163.com/dashi']
Traceback (most recent call last):
  File "imap_select.py", line 26, in <module>
    c.close()
  File "/usr/lib/python2.7/imaplib.py", line 382, in close
    typ, dat = self._simple_command('CLOSE')
  File "/usr/lib/python2.7/imaplib.py", line 1070, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "/usr/lib/python2.7/imaplib.py", line 825, in _command
    ', '.join(Commands[name])))
imaplib.error: command CLOSE illegal in state AUTH, only allowed in states SELECTED

=====
然后是163邮件服务器向我发送一封有关此邮件:

===== And then the 163 mail server send me a mail,about this:

该行为存在以下安全隐患:
1) 邮件客户端未经有效识别,不能有效保证帐户安全性,存在帐号密码泄漏的风险;
2) 数据传输安全性低,存在数据泄漏风险。

英文为:

1) mail client not a security client 
2) data streaming is notsecruity

非常感谢。
这是调试信息。
我认为我必须具有TLS1.2版本连接。

Thanks a lot. This is the debug info . I think that I must a have a TLS1.2 version conection.

  05:59.52 > ENFK1 LOGIN "tmailest@163.com" "aaannnmmm"
  05:59.54 < ENFK1 OK LOGIN completed
  05:59.54      matched r'(?P<tag>ENFK\d+) (?P<type>[A-Z]+) (?P<data>.*)' => ('ENFK1', 'OK', 'LOGIN completed')
  05:59.54 > ENFK2 SELECT INBOX
  05:59.54 < ENFK2 NO SELECT The login is not safe! Please update your mail client: http://mail.163.com/dashi
  05:59.54      matched r'(?P<tag>ENFK\d+) (?P<type>[A-Z]+) (?P<data>.*)' => ('ENFK2', 'NO', 'SELECT The login is not safe! Please update your mail client: http://mail.163.com/dashi')
  05:59.54 NO response: SELECT The login is not safe! Please update your mail client: http://mail.163.com/dashi
NO ['SELECT The login is not safe! Please update your mail client: http://mail.163.com/dashi']
Traceback (most recent call last):
  File "imapselect.py", line 31, in <module>
    c.close()
  File "/usr/lib64/python2.6/imaplib.py", line 375, in close
    typ, dat = self._simple_command('CLOSE')
  File "/usr/lib64/python2.6/imaplib.py", line 1060, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "/usr/lib64/python2.6/imaplib.py", line 818, in _command
    ', '.join(Commands[name])))
imaplib.error: command CLOSE illegal in state AUTH, only allowed in states SELECTED


推荐答案

您自己的客户,他们将通过 mail@service.netease.com 网易邮箱提醒:阻止了一次不安全的收信请求的电子邮件c>。

After netease blocking your own client, they will send you an email named 网易邮箱提醒:阻止了一次不安全的收信请求 by mail@service.netease.com.

在电子邮件底部,他们提供了指向配置页面的链接:

On the bottom of the email, they provided a link to the configure page:

< a href = http://config.mail.163.com/settings/imap/index.jsp?uid=YOUR_EMAIL_NAME@126.com rel = nofollow> http://config.mail.163.com/ settings/imap/index.jsp?uid=YOUR_EMAIL_NAME@126.com

自己替换 YOUR_EMAIL_NAME

这篇关于python登录163邮件服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆