From 7cd59d20938ad750e454670d6326a3ccc95e0979 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 7 Nov 2023 17:49:49 +0100 Subject: [PATCH] fixing contact form --- rowers/templates/contactformemail.html | 24 ++++++++++++++++++++++++ rowers/views/statements.py | 21 +++++++++++++++++---- 2 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 rowers/templates/contactformemail.html diff --git a/rowers/templates/contactformemail.html b/rowers/templates/contactformemail.html new file mode 100644 index 00000000..6ac0a5fa --- /dev/null +++ b/rowers/templates/contactformemail.html @@ -0,0 +1,24 @@ +{% extends "emailbase.html" %} + +{% block body %} +

New Contact Form Message

+ +

+ From: {{ firstname }} {{ lastname }} +

+

+ Email: {{ email }} +

+

+ Subject: {{ subject }} +

+ +

+ {{ message }} +

+ + +

+ Best Regards, the Rowsandall Team +

+{% endblock %} diff --git a/rowers/views/statements.py b/rowers/views/statements.py index 88d24d87..5c07b20e 100644 --- a/rowers/views/statements.py +++ b/rowers/views/statements.py @@ -1290,11 +1290,24 @@ def sendmail(request): subject = 'Rowsandall Contact Form:'+form.cleaned_data['subject'] message = form.cleaned_data['message'] fullemail = firstname + " " + lastname + " " + "<" + email + ">" - try: - send_mail(subject, message, fullemail, ['info@rowsandall.com']) - except: + d = { + 'firstname': firstname, + 'lastname': lastname, + 'email': email, + 'subject': subject, + 'message': message, + } + res = send_template_email('Rowsandall ', + ['Rowsandall '], + subject, + 'contactformemail.html', + d + ) + if res: + messages.info(request,"Your contact form was submitted") + else: messages.error( - request, "Something went wrong trying to send the email") + request, "Something went wrong trying to send the form") return HttpResponseRedirect('/rowers/email/thankyou/') else: if not success: