import yagmail username = '账号' password = '授权码' smtp = 'smtp.163.com' mail = yagmail.SMTP(user=username,password=password,host=smtp) to = 'xxxxxx@126.com' cc = 'aaaaaaa@126.com' subject = '标题' content = '内容' fils = [r'文件绝对路径',r'文件绝对路径'] mail.send(to=to,cc=cc,subject=subject,contents=content,attachments=fils)