Gmail "Daha az güvenli uygulama erişimine izin ver" ayarını açın. Python kodunuzu aşağıdaki gibi güncelleyin.
from flask import Flask, render_template, request, jsonify
from flask_mail import Mail, Message

app = Flask(__name__, template_folder='template')

app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USE_SSL'] = False
app.config['MAIL_USERNAME'] = 'asker244897@gmail.com'
app.config['MAIL_PASSWORD'] = 'wovivtrwmfzedsef'

mail = Mail(app)

@app.route("/")
def home():
    return render_template("index.html", hata="")

@app.route("/users", methods=['GET', 'POST'])
def index():
    if request.method == 'POST':
        name = request.form.get('name')
        phone = request.form.get('phone')
        email = request.form.get('email')
        message = request.form.get('message')

        try:
            msg = Message('Mesaj', sender=app.config['MAIL_USERNAME'], recipients=['asker244897@gmail.com'])
            msg.body = f"Name: {name}\nPhone: {phone}\nEmail: {email}\nMessage: {message}"
            mail.send(msg)
            return jsonify({"success": True})
        except Exception as e:
            return jsonify({"error": str(e), "success": False})

    return render_template("index.html", hata="")

if __name__ == "__main__":
    app.run(debug=True)