mirror of
https://github.com/FAUSheppy/flask-json-dream-website
synced 2025-12-07 08:31:36 +01:00
fix typos
This commit is contained in:
@@ -16,6 +16,9 @@ from werkzeug.routing import BuildError
|
|||||||
from werkzeug.utils import ImportStringError
|
from werkzeug.utils import ImportStringError
|
||||||
import xml.etree.ElementTree as et
|
import xml.etree.ElementTree as et
|
||||||
|
|
||||||
|
# import project files
|
||||||
|
import smtp
|
||||||
|
|
||||||
# paths
|
# paths
|
||||||
SECTIONS_DIR = "sections/"
|
SECTIONS_DIR = "sections/"
|
||||||
NEWS_DIR = "news/"
|
NEWS_DIR = "news/"
|
||||||
|
|||||||
12
smtp.py
12
smtp.py
@@ -1,19 +1,18 @@
|
|||||||
import sys
|
import sys
|
||||||
import smtplib
|
import smtplib
|
||||||
import smtplib.SMTPException
|
|
||||||
|
|
||||||
def checkSMTPConnection(app):
|
def checkSMTPConnection(app):
|
||||||
'''Check connection and login on SMTP server configured in app config'''
|
'''Check connection and login on SMTP server configured in app config'''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not all([ x in app.conf for x in ["TARGET_SMTP", "TARGET_EMAIL"]:
|
if not all([ x in app.config and app.config[x] for x in ["TARGET_SMTP", "TARGET_EMAIL"]]):
|
||||||
raise smtplib.SMTPException("Missing Configuration.")
|
raise smtplib.SMTPException("Missing Configuration.")
|
||||||
smtpTarget = smtplib.SMTP(app.config["TARGET_SMTP"])
|
smtpTarget = smtplib.SMTP(app.config["TARGET_SMTP"])
|
||||||
if app.config["TARGET_SMTP_USER"] and app.config["TARGET_SMTP_PASSWORD"]:
|
if app.config["TARGET_SMTP_USER"] and app.config["TARGET_SMTP_PASSWORD"]:
|
||||||
smtp.login(app.config["TARGET_SMTP_USER"], app.config["TARGET_SMTP_PASSWORD"])
|
smtp.login(app.config["TARGET_SMTP_USER"], app.config["TARGET_SMTP_PASSWORD"])
|
||||||
smtpTarget.quit()
|
smtpTarget.quit()
|
||||||
except smtplib.SMTPException as e:
|
except smtplib.SMTPException as e:
|
||||||
if app.config["STMP_MUST_BE_CONNECTED"]:
|
if app.config["SMTP_MUST_BE_CONNECTED"]:
|
||||||
print(e, file=sys.stderr)
|
print(e, file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
@@ -22,11 +21,12 @@ def checkSMTPConnection(app):
|
|||||||
def sendMailFromHtmlForm(app, htmlForm):
|
def sendMailFromHtmlForm(app, htmlForm):
|
||||||
'''Take the app config and the contact HTML-form and send a mail accordingly'''
|
'''Take the app config and the contact HTML-form and send a mail accordingly'''
|
||||||
|
|
||||||
email = htmlForm["email"]
|
email = htmlForm["email"]
|
||||||
name = htmlForm["name"]
|
name = htmlForm["name"]
|
||||||
message = htmlForm["message"]
|
message = htmlForm["message"]
|
||||||
|
subject = htmlForm["subject"]
|
||||||
|
|
||||||
subject = "Subject: {} ({})\n\n".format(flask.request.form["subject"], name)
|
subject = "Subject: {} ({})\n\n".format(subject, name)
|
||||||
|
|
||||||
smtpTarget = smtplib.SMTP(app.config["TARGET_SMTP"])
|
smtpTarget = smtplib.SMTP(app.config["TARGET_SMTP"])
|
||||||
smtpTarget.sendmail(email, app.config["TARGET_EMAIL"] , message)
|
smtpTarget.sendmail(email, app.config["TARGET_EMAIL"] , message)
|
||||||
|
|||||||
Reference in New Issue
Block a user