import yagmail yag = yagmail.SMTP(user="*@163.com", password="授权码", host='smtp.163.com') contents = [errorstr] yag.send('*@qq.com', 'title', contents) yag.close() 上方授权码获取方法(以163邮箱为例): 登录‘user’邮箱 点击‘新增授权密码’,获取到的码填到password处即可