def sendmail(request): if request.POST: form = EmailForm(request.POST) if form.is_valid(): firstname = form.cleaned_data['firstname'] lastname = form.cleaned_data['lastname'] email = form.cleaned_data['email'] subject = form.cleaned_data['subject'] message = form.cleaned_data['message'] try: send_mail('subject', 'message', '<SENDER EMAIL ID>', ['<RECEIVER EMAIL ID"S>']) return HttpResponseRedirect('/email/thankyou/') except Exception, e: return HttpResponse('Except Block executed.' + str(e)) else: return HttpResponse("Form not Valid")
def sendmail(request): if request.method == 'POST': form = EmailForm(request.POST) if form.is_valid(): firstname = form.cleaned_data['firstname'] lastname = form.cleaned_data['lastname'] email = form.cleaned_data['email'] subject = form.cleaned_data['subject'] botcheck = form.cleaned_data['botcheck'] message = form.cleaned_data['message'] area = form.cleaned_data['area'] if botcheck: try: fullemail = firstname + " " + lastname + " " + "<" + email + ">" send_mail(subject, message, fullemail, ['*****@*****.**']) return HttpResponseRedirect('/contact/thankyou/') except: return HttpResponseRedirect('/contact/') else: return HttpResponseRedirect('/contact/') else: return HttpResponseRedirect('/contact/')