On Wednesday, 1 June 2011 08:01:33 UTC+1, Pulkit Mehrotra wrote: > > I am trying to make a contact us form which will send a mail to me using > the smtp server .It will load the thank you page after form submission > .Everything is working something ,the thank you page is loading and i am not > getting any errors ,but i am not getting the mails. > > here is my views.py file.: > from django.shortcuts import render_to_response > from django.core.mail import send_mail > from django.http import HttpResponseRedirect > from django.template import RequestContext > def contacts(request): > errors=[] > if request.method=='POST': > if not request.POST.get('subject',''): > errors.append('Enter a subject') > if not request.POST.get('email') and '@' not in > request.POST['email']: > errors.append('Enter a valid email address') > if not errors: > send_mail( > request.POST['subject'], > request.POST['message'], > request.POST.get('email','mehrotr...@gmail.com'), > ['mehrotr...@gmail.com'], > ) > return HttpResponseRedirect('/contact/thankyou/') > return render_to_response('form.html',{ > 'errors':errors, > 'subject':request.POST.get('subject',''), > 'email':request.POST.get('email',''), > },context_instance=RequestContext(request)) >
Why don't you use an actual Django form? It will take care of the validation for you. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/bFVfQm1CdU1SMW9K. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.