smtp funktioniert mit Variablen

This commit is contained in:
2024-01-15 22:30:59 +01:00
parent 185d75caba
commit 9c7e14544d

9
app.py
View File

@@ -4,9 +4,9 @@ import smtplib, ssl
port = 587 # For starttls port = 587 # For starttls
smtp_server = "smtp.gmail.com" smtp_server = "smtp.gmail.com"
sender_email = "patha9201@gmail.com" sender_email = "patha9201@gmail.com"
receiver_email = "patha9201@gmail.com" # receiver_email = "patha9201@gmail.com"
password = "dqlw ablc clic uvgp" password = "dqlw ablc clic uvgp"
message = "test"
app = Flask(__name__) app = Flask(__name__)
@@ -23,8 +23,9 @@ def form():
if request.method == 'GET': if request.method == 'GET':
return render_template('form.html') return render_template('form.html')
if request.method == 'POST': if request.method == 'POST':
user = request.form['name'] receiver = request.form['name']
mail = request.form['email'] receiver_email = request.form['email']
message = f"Sehr geehrter Herr {receiver},"
context = ssl.create_default_context() context = ssl.create_default_context()
with smtplib.SMTP(smtp_server, port) as server: with smtplib.SMTP(smtp_server, port) as server: