I want to send a message with personalized SMTP mail-in Django. Where I want to send the Name, email, and contact information with the dynamic text input value.
Here is my code
if request.method == 'POST':
name = request.POST.get('name')
email = request.POST.get('email')
contact = request.POST.get('contactnum')
textmess = request.POST.get('textarea')
allinfo = "Name : " + name, "E-Mail" + email, "Contact:" + contact, textmess
print (allinfo)
subject = 'From MBS Project(Contact Us)'
email_from = settings.EMAIL_HOST_USER
mailto:recipents_list=['abc@gmail.com']
if allinfo:
sendMail = send_mail(subject, allinfo, email_from, recipents_list)
messages.success(request, 'Message Send Successfully...')
return HttpResponseRedirect('contactus', {'sendMail': sendMail})
else:
messages.error(request, 'error during send!!, Please Try Again..')
return render(request, 'contactus.html', {})
else:
return render(request, 'contactus.html', {})