1、发送邮件
import yagmail username = ‘xxxxx@126.com‘ #邮箱账号 password = ‘xxxxx722123456‘#邮箱授权码 smtp = ‘smtp.126.com‘#邮箱服务器地址 mail=yagmail.SMTP(user=username,password=password,host=smtp)#连接邮箱服务器 to=[‘xxxx@qq.com‘,‘xxxx@qq.com‘] cc=‘xxxx@qq.com‘ subject=‘交作业‘ content=‘test‘ attach=[r‘C:\Users\zhang\Desktop\5.jpg‘,r‘C:\Users\zhang\Desktop\名单.xlsx‘] mail.send(to=to,cc=cc,subject=subject,contents=content,attachments=attach)#发送邮件
原文:https://www.cnblogs.com/wmxgreat/p/11074903.html