Private
Public Access
1
0

fixing contact form

This commit is contained in:
2023-11-07 17:49:49 +01:00
parent 9a6d3ae4c2
commit 7cd59d2093
2 changed files with 41 additions and 4 deletions

View File

@@ -0,0 +1,24 @@
{% extends "emailbase.html" %}
{% block body %}
<p>New Contact Form Message</p>
<p>
From: {{ firstname }} {{ lastname }}
</p>
<p>
Email: {{ email }}
</p>
<p>
Subject: {{ subject }}
</p>
<p>
{{ message }}
</p>
<p>
Best Regards, the Rowsandall Team
</p>
{% endblock %}

View File

@@ -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 <info@rowsandall.com>',
['Rowsandall <info@rowsandall.com>'],
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: