import yamail # import yagmail #发附件的附件如果是中文名是乱码 username = 'testing_dhcc@163.com' passwd = 'aaaaaaa'#授权码 # smtp = yamail.SMTP(host='smtp.qq.com', # user=username, # password=passwd, # smtp_ssl = True) smtp = yamail.SMTP(host='smtp.163.com', user=username, password=passwd) smtp.send(to=['1334933924@qq.com','testing_dhcc@163.com'],#163邮箱收件人中要带上自己,否则报错 cc='1334933924@qq.com',#若cc 为空直接删除本项 subject='test', contents='133354', attachments=r'E:studyscriptspythonTMZ0day6sys模块.py' ) smtp.close()