python:发邮件

import yagmail
username='test@163.com'
password='test123'   #免费邮箱,这里用授权码,一般自己公司的直接写邮箱密码即可
smtp='smtp.163.com'    #注意这里是smtp.163.com,不是smtp@163.com。不要写错
mail=yagmail.SMTP(user=username,password=password,host=smtp)   #链接邮箱
to =['hehe#163.com','454797@qq.com']     #多个收件人传list
cc='14464564646@qq.com'
subject='test'
content='内容'
files=[r'E:\BestTest\上课内容\处女座学员名单.xlsx','E:\BestTest\上课内容\QQ图片20190603150645.jpg']   #多个附件用list
mail.send(to=to,cc=cc,subject=subject,contents=content,attachements=files)
# to:收件人,cc:抄送人,subject:标题,contents:内容;attachments:附件
#原pip安装的yagmail,发邮件带中文附件会有乱码,使用牛牛的.whl文件。E:\BestTest\上课内容\课程\yagmail-0.10.212-py2.py3-none-any.whl

 

posted @ 2019-06-26 13:39  4jd121de2gf4e2sa5d  阅读(139)  评论(0编辑  收藏  举报