import linecacheimport smtplibimport timeimport linecacheimport random#算出txt的行数,163账号_2.txt中,每一行都存储一个账号密码! txt = open(r'F:\163账号_2.txt','r') data = txt.read() txt.close() n = data.count('\n')print("总行数",n)#选取随机的数i = random.randint(1, (n+1))print("本次使用的行数",i)print("===========================")###得到对应的i行的数据line=linecache.getline(r'F:\163账号_2.txt',i)#切片实现分离出账号和密码user = line.split("----")[0]password = line.split("----")[1].replace('\n','')print(user)print(password)try: #发送邮箱的账号/密码 smtpserver = "smtp.163.com" smtp = smtplib.SMTP() smtp.connect(smtpserver) smtp.login(user,password) print("邮箱登陆成功!") print("第",(i-1),"行账号有效") time.sleep(1)except: print("邮箱登陆失败,请重新输入!") time.sleep(1)
*这样虽然可以实现163邮箱的登录,但是可能会被锁定ip
*备注账号文档在上传的文件: