so I'm wanting to make this form where the client fills their name, email and a message. Then that message and their name is sent to my mail address and another mail is sent from my address to the clients one telling that their mail was sent successfully. I already did this on another project and literally just copied changing the name of the functions n stuff but it doesn't work.
views.py
def send_email(email):
context = {'email': email}
template = get_template('emails/message-confirmation.html')
content = template.render(context)
email = EmailMultiAlternatives(
'Test email',
'AmiSalta message confirmation',
settings.EMAIL_HOST_USER,
[email]
)
email.attach_alternative(content, 'text/html')
email.send()
def function(request):
form = ContactForm_es()
if request.method == 'POST':
email = request.POST.get('email')
send_mail(email)
form = ContactForm_es(request.POST)
if form.is_valid():
email = form.cleaned_data['email']
full_name = form.cleaned_data['full_name']
body = form.cleaned_data['body']
send_mail(full_name,body,email, ['******@gmail.com'])
return render(request, 'es/home.html', {
'form': form,
})
I'm going crazy bc is the last thing I need to do and I already did once but I just can't make it work. Please if someone knows what's wrong let me know, thanks in advance.