第一步:安装
pip install yagmail

第二步:使用

import yagmail
with yagmail.SMTP(user="youxiang",password="mima",host="smtp.qq.com",port=465) as yag:
    contents=[u'我是内容',u"/root/桌面/home.pdf",u'还有附件,不看顺序',u'/root/桌面/b.docx']
    yag.send(to=["mytest@qq.com"],cc=["mytestcc@163.com"],subject=u"测试",contents=contents)

———————————————————————————————————————————————

#!/usr/bin/python
# -*- coding: utf-8 -*-
import yagmail
import sys
smtpaddr = 'smtp.163.com'
myemail='xxx@163.com'
password='13xxxx'

recvmail=sys.argv[1]
subject=sys.argv[2]
content=sys.argv[3]
with yagmail.SMTP(user=myemail,password=password,host=smtpaddr,port=465) as yag:
    yag.send(to=[recvmail],subject=subject,contents=content)

 

发表评论

邮箱地址不会被公开。 必填项已用*标注