代码语言:js复制
from flask import Flask
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='你的QQ号',
MAIL_PASSWORD='邮箱密码'
)
mail = Mail(app)
@app.route('/')
def index():
msg = Message(subject="mongo", sender='发送者邮箱', recipients=['接收者邮箱'])
msg.html='<h1>hello world!</h1>'
mail.send(msg)
return "hello_world"
if __name__ == '__main__':
app.run()