三行代码实现邮件发送

# coding:utf-8
import yagmail
def apitestreport_to_email():
   # 第一行,链接登录邮箱服务器
   yag = yagmail.SMTP(user="leo@qq.com", password="123456", host='smtp.exmail.qq.com')
   # 第二行,邮箱正文
   contents = ['测试详情:','<a href="http://127.0.0.1/apitestreport/>Click me']
   # 第三行,发送邮件
   yag.send('leo@qq.com', '接口自动化测试报告',contents)
if __name__=='__main__':
    apitestreport_to_email()


先安装pip install yagmail,或下载安装包后python setup.py install。

摸摸哒~!


来源:http://www.autotestplat.com/topics/detail/60/


推荐阅读:

原文地址:https://www.cnblogs.com/finer/p/11895122.html