这个邮件发送弄了好一会,后来才发现是我的163邮箱有点问题,后来换成QQ邮箱就好了。记录下自己的,方便日后有用。

import smtplib
from email.mime.text import MIMEText
from email.header import Header

# 第三方 SMTP 服务
mail_host = "smtp.qq.com"  # 设置服务器
mail_user = "发送QQ邮箱账号"  # 用户名
mail_pass = "自己的口令"  # 口令

sender = '发送QQ邮箱账号'
receivers = [邮箱1","邮箱2"]  # 接收邮件,可设置为你的QQ邮箱或者其他邮箱,可以多个,逗号分开

message = MIMEText('你好', 'plain', 'utf-8')
message['From'] = Header("hello——530519174", 'utf-8')
message['To'] = Header("title_me", 'utf-8')

subject = '在么在么'  # 标题不要含有test等标志
message['Subject'] = Header(subject, 'utf-8')

smtpObj = smtplib.SMTP()
smtpObj.connect(mail_host, 25)  # 25 为 SMTP 端口号
smtpObj.login(mail_user, mail_pass)
smtpObj.sendmail(sender, receivers, message.as_string())
print("邮件发送成功")

参考:https://www.runoob.com/python/python-email.html