import smtplib
from email.message import EmailMessage
HOST = "smtp.qq.com"
PORT = 25
SENDER = ""#开启smtp服务的邮箱
PASSWORD = ""#开启邮箱时的授权码
smt = smtplib.SMTP(host=HOST, port=PORT)
MSG = EmailMessage()
MSG["From"] = SENDER
def sendMessage(recever, msg):
smt.login(user=SENDER, password=PASSWORD)
MSG["To"] = recever
MSG["Subject"] = msg
smt.send_message(MSG)
smt.quit()
记录一下