大家好,又见面了,我是全栈君。
python flask-mail 实现qq发送邮件
from flask import Flask,jsonify
from flask_mail import Mail,Message
app = Flask(__name__)
app.config.update( MAIL_SERVER='smtp.qq.com',
MAIL_PORT='465',
MAIL_USE_SSL=True,
MAIL_USERNAME='246984691',#使用qq,不是邮箱
MAIL_PASSWORD='ohkpwzgfmsldiji')#config配置
mail = Mail(app)
@app.route("/")
def send_message():
msg = Message("Hello",#主题
sender="[email protected]",#发送人邮箱
recipients=["[email protected]"])#接收人邮箱
msg.body="发送成功"#消息主体
mail.send(msg)
return jsonify({"msg":"发送成功"})
if __name__ == '__main__':
app.run(host='127.0.0.1', port=80, debug=True)
复制
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/111375.html原文链接:https://javaforall.cn