SMTP eingefügt
This commit is contained in:
18
app.py
18
app.py
@@ -1,4 +1,12 @@
|
|||||||
from flask import Flask, render_template, request, redirect, url_for
|
from flask import Flask, render_template, request, redirect, url_for
|
||||||
|
import smtplib, ssl
|
||||||
|
|
||||||
|
port = 587 # For starttls
|
||||||
|
smtp_server = "smtp.gmail.com"
|
||||||
|
sender_email = "patha9201@gmail.com"
|
||||||
|
receiver_email = "patha9201@gmail.com"
|
||||||
|
password = "dqlw ablc clic uvgp"
|
||||||
|
message = "test"
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@@ -16,6 +24,16 @@ def form():
|
|||||||
return render_template('form.html')
|
return render_template('form.html')
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
user = request.form['name']
|
user = request.form['name']
|
||||||
|
mail = request.form['email']
|
||||||
|
|
||||||
|
context = ssl.create_default_context()
|
||||||
|
with smtplib.SMTP(smtp_server, port) as server:
|
||||||
|
server.ehlo() # Can be omitted
|
||||||
|
server.starttls(context=context)
|
||||||
|
server.ehlo() # Can be omitted
|
||||||
|
server.login(sender_email, password)
|
||||||
|
server.sendmail(sender_email, receiver_email, message)
|
||||||
|
|
||||||
return redirect(url_for('submitted'))
|
return redirect(url_for('submitted'))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<center>
|
<center>
|
||||||
<br><br>
|
<br><br>
|
||||||
<h1>Trauzeugen-Antragsformular 38b/2</h1>
|
<h1>Trauzeugen-Antragsformular gem. Passierschein A38</h1>
|
||||||
<form action='#' method='post'>
|
<form action='#' method='post'>
|
||||||
<br><br>
|
<br><br>
|
||||||
<p> Name:</p>
|
<p> Name:</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user