错误信息:
一、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···
前置工作—重点
1、登录谷歌邮箱启用pop,IMAP,保存更改
2、进入谷歌账户>安全>开启不太安全的应用程序访问
3、设置-----允许任何设备登录访问
这里连接
4、代码
import zmail
class 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 mail
m = Email('example@gmail.com', 'password')
m.read_email()