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
|
||||
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__)
|
||||
|
||||
@@ -16,6 +24,16 @@ def form():
|
||||
return render_template('form.html')
|
||||
if request.method == 'POST':
|
||||
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'))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user