发邮件

import yagmail

username = '104628703@qq.com'
password = 'sdg34234' #免费的邮箱,这里用授权码,一般自己公司的,直接写邮箱密码就行了。
smtp = 'smtp.qq.com'


mail = yagmail.SMTP(user=username,password=password,host=smtp)

to = ['974219141@qq.com','511402865@qq.com','104628703@qq.com','540493450@qq.com']
cc = ['690942492@qq.com','931279527@qq.com','525586735@qq.com']

subject = '交作业'
content = '下节课交作业,不然发红包!'
files = [r'/Users/nhy/PycharmProjects/cnz/day5/student.xlsx',
r'/Users/nhy/PycharmProjects/cnz/day5/删除三天前的日志.py']
mail.send(to=to,cc=cc,subject=subject,contents=content,
attachments=files)

posted on 2019-06-27 17:09  静思的技术博客  阅读(121)  评论(0编辑  收藏  举报

导航