Flask Web development chapter 7, after adjusting the project structure, found that new users will not send e-mail?

problem description

Flask Web development chapter 7, after adjusting the project structure, found that new users will not send mail, there is no error prompt (chapter 6 debugging is able to send mail). I have checked junk mailboxes that are not in my inbox and there is no bounce behavior

the environmental background of the problems and what methods you have tried

Baidu hasn"t found a good solution for a long time. The console has the following error, but it feels irrelevant:
DVV pythonlibsitelypackagespymysqlcursors.pyrang170: Warning: (1366, "Incorrect string value:"\ xD6\ xD0\ xB9\ xFA\ xB1\ xEA." for column "VARIABLE_VALUE" at row 48
4")

related codes

Program structure:

Code section:
config.py file
import os

basedir = os.path.abspath (os.path.dirname (_ _ file__))

class Config:

SECRET_KEY = "hard to guess string"
SQLALCHEMY_COMMIT_OM_TEARDOWN = True
FLASKY_MAIL_SUBJECT_PREFIX = "[FLASKY]"
FLASKY_MAIL_SENDER = "Flasky Admin <********@163.com>"
FLASKY_ADMIN = "*********@qq.com"

@staticmethod
def init_app(app):
    pass

class DevelopmentConfig (Config):

DEBUG = True
SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:root@localhost/flask"

class TestConfig (Config):

TESTING = True
MAIL_SERVER = "smtp.163.com"
MAIL_PORT = 25
MAIL_USE_TLS = False
MAIL_USE_SSL = False
MAIL_USERNAME = "*********@163.com"
MAIL_PASSWORD = "*******"
SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:root@localhost/flask"

class ProductionConfig (Config):

pass

config = {

"development":DevelopmentConfig,
"testing":TestConfig,
"production":ProductionConfig,
"default":TestConfig

}

email.py file
from threading import Thread
from flask import current_app, render_template
from flask_mail import Message
from. Import mail

def send_async_mail (app, msg):

with app.app_context():
    mail.send(msg)

def send_mail (to, subject, template, * * kwargs):

app = current_app._get_current_object()
if app.config["FLASKY_ADMIN"]:
    msg = Message(app.config["FLASKY_MAIL_SUBJECT_PREFIX"]  + subject,\
                  sender=app.config["FLASKY_MAIL_SENDER"], recipients=[to])
    msg.body = render_template(template + ".txt", **kwargs)
    msg.html = render_template(template + ".html", **kwargs)
    thr = Thread(target=send_async_mail, args=(app, msg))
    thr.start()
    return thr
    

view.py file
from flask import render_template, session, redirect, url_for, current_app
from. Import main
from .forms import NameForm
from.. Import db
from.. models import User
from.. email import send_mail

@ main.route ("/", methods= ["GET"," POST"])
def index ():

form = NameForm()
if form.validate_on_submit():
    user = User.query.filter_by(username=form.name.data).first()    -sharp 
    if user is None:    -sharp 
        user = User(username=form.name.data)
        db.session.add(user)
        session["known"] = False    -sharp session knownFalseweb
        if current_app.config["FLASKY_ADMIN"]:  -sharp flasky
            -sharp 
            send_mail(current_app.config["FLASKY_ADMIN"], "New User", "mail/new_user", user=user)
    else:
        session["known"] = True
    session["name"] = form.name.data
    return redirect(url_for(".index"))  -sharp redirect
return render_template("index.html", form=form, name=session.get("name"),
                       known=session.get("known", False))
                       

app/__init__.py file
from flask import Flask, render_template
from flask_bootstrap import Bootstrap
from flask_sqlalchemy import SQLAlchemy
from flask_mail import Mail
from flask_moment import Moment
from config import config

bootstrap = Bootstrap ()
mail = Mail ()
db = SQLAlchemy ()

def create_app (config_name):

app = Flask(__name__)
app.config.from_object(config[config_name])
config[config_name].init_app(app)
bootstrap.init_app(app)
mail.init_app(app)
db.init_app(app)

from .main import main as main_blueprint
app.register_blueprint(main_blueprint)

return app
          

what result do you expect? What is the error message actually seen?

after the program runs, enter the user name, there is no error, but also did not receive the new user to join the e-mail, how to receive the e-mail. I can"t see what went wrong

Jul.18,2021
Menu