From 37ab6ba6cabcc7038d2848219db4695c6267ddc6 Mon Sep 17 00:00:00 2001 From: asauer Date: Sat, 13 Apr 2019 20:07:06 +0200 Subject: [PATCH] Give the mail delivery a try - fail --- gruppenbildungsspiel.py | 17 +++++++++++++++++ templates/base.html | 5 +++++ templates/questions.html | 1 - 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gruppenbildungsspiel.py b/gruppenbildungsspiel.py index 402df9a..5d21782 100644 --- a/gruppenbildungsspiel.py +++ b/gruppenbildungsspiel.py @@ -2,6 +2,8 @@ from flask import Flask, render_template, request, redirect, url_for import uuid import csv import os +import smtplib +from email.message import EmailMessage from wtforms import Form, StringField, SelectField, RadioField, TextAreaField, BooleanField, validators from wtforms.fields.html5 import EmailField @@ -11,6 +13,7 @@ app.jinja_env.lstrip_blocks = True datafile = "data.csv" solutionfile = "solutions.csv" +mailfile = "mail.csv" def check_input(form, field): if field.data == 'default': @@ -60,6 +63,20 @@ class AnswerForm(Form): def index(): return render_template('index.html', title='Sortierhut') +def send_mail(user_id): + with open(mailfile) as f: + msg = EmailMessage() + msg.set_content(f.read()) + + msg['Subject'] = 'Deine Sortierhut-ID' + msg['From'] = 'anna-carina-dorothea.sauer@stud.uni-bamberg.de' + msg['To'] = 'anna-carina-dorothea.sauer@stud.uni-bamberg.de' + + s = smtplib.SMTP('localhost') + s.send_message(msg) + s.quit() + return + @app.route('/questions', methods=['GET', 'POST']) def questions(): form = QuestionForm(request.form) diff --git a/templates/base.html b/templates/base.html index 655a1dc..d6e125b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -22,5 +22,10 @@ {% block content %} {% endblock %} + diff --git a/templates/questions.html b/templates/questions.html index 803f74b..4dde572 100644 --- a/templates/questions.html +++ b/templates/questions.html @@ -8,7 +8,6 @@ {{ render_field(form.spirit_animal) }} {{ render_field(form.operating_system) }} {{ form.check }} {{ form.check.label }} - {{ render_field(form.email) }}