import smtplib from email.mime.text import MIMEText from email.utils import formataddr msg = MIMEText('邮件内容', 'plain', 'utf-8') msg['From'] = formataddr(["jassin", 'jassin_du@163.com']) # 来自于哪里 msg['To'] = formataddr(["xxx", '316223167@qq.com']) # 发送于 msg['Subject'] = "Pytohn开发面试邀请" # 主题 server = smtplib.SMTP("smtp.163.com", 25) server.login("jassin_du@163.com", "xxx") # 邮箱 账户密码 server.sendmail('jassin_du@163.com', ['316223167@qq.com', ], msg.as_string()) server.quit()