错误信息:
一、Please log in via your web browser and then try again.\n5.7.14 Learn more···
二、poplib.error_proto: b’-ERR [AUTH] Web login required: https://support.google···
三、534, b’5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbt\n5.7.14 hX7S5mVfSC1JGt_GW4O39lYYeOgIBva9TcylO3hwbeazy-a3ac1Ao0Ke_BRRmC660GcbP\n5.7.14 YUi8sGc6zCsuwdgDhQHA71LNMnUKfx3pvt3xfgfBYczpSCn0-hw-bt9sFQ-2BaQQ>\n5.7.14 Please log in via your web browser and then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 q24sm17744451pgk.32 - gsmtp’ 这个直接转第三步
前置工作—重点
1、登录谷歌邮箱启用pop,IMAP,保存更改
2、进入谷歌账户>安全>开启不太安全的应用程序访问
3、设置-----允许任何设备登录访问>点击 继续
访问这个链接https://accounts.google.com/DisplayUnlockCaptcha
4、代码
import zmailclass Email:def __init__(self,username='',password=''):self.server = zmail.server(username=username,password=password)def send_email(self,account:list,content):self.server.send_mail(recipients=account,mail=content)def read_email(self):if self.server.smtp_able():print('smtp_able')if self.server.pop_able():print('pop')mail = self.server.get_latest()zmail.show(mail)def search_email(self,sender):mail = self.server.get_mails(sender=sender)return mailm = Email('example@gmail.com', 'password')
m.read_email()