flask 的email
#_*_coding:utf-8_*_
from flask import Flask
from flask_mail import Mail,Message
app = Flask(__name__)
# 配置邮件:服务器/端口/传输层安全协议/邮箱名/密码
app.config.update(
DEBUG=True,
MAIL_SERVER = 'smtp.qq.com',
MAIL_PORT=465,
MIAL_USE_TLS=True,
MAIL_USERNAME='1076471539@qq.com',
MIAL_PASSWORD = 'sdfaffewfsdfa'
)
mail = Mail(app)
@app.route('/')
def index():
# sender 发送方, recipients接收列表
msg = Message('This is a test',sender='1076471539@qq.com',recipient=['1076471539@qq.com',])
msg.body = 'Flask test mail'
mail.send(msg)
print('mail send')
return 'Send Success'
写入自己的博客中才能记得长久