上代码:
import yagmail sendmail = '[email protected]' sendpswd = 'xxx' receivemail = '[email protected]' # 连接邮箱服务器 yag = yagmail.SMTP(user=sendmail, password=sendpswd, host='smtp.126.com') # 邮件正文 contents = ['第一段', '自动化', '报告邮件'] #附件地址 fujian = ["/Users/zhan/zhan/Autotest/report/2018-09-11_09_52_24_report.html"] # 发送邮件 yag.send(receivemail, '《自动化报告》', contents,fujian)