"to" has to be a list: ['[EMAIL PROTECTED]'] patrick
Am 03.11.2006 um 20:08 schrieb [EMAIL PROTECTED]: > > So, I've got a contact form so people can email me, or, if a username > is passed in the URL, site members can email each other. It works > fine, > at least so far as I can tell. People get the emails, in other words. > > The weirdness is in the "TO:" fields the recipient sees: They look > something like this: > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; > [EMAIL PROTECTED]; > [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]; > [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]; > [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]; > [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]; > [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]; > [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]; > [EMAIL PROTECTED]; "."@ruble.dreamhost.com; [EMAIL PROTECTED]; > [EMAIL PROTECTED]; "."@ruble.dreamhost.com; [EMAIL PROTECTED]; > [EMAIL PROTECTED] > Subject: Gretsch Pages contact form message > > The flaky part is that the recipient ISN'T in there, but they get it. > > Here's the view: > > from django.core import mail, validators > from django import forms > from django.http import HttpResponseRedirect > from django.shortcuts import render_to_response > from pprint import pformat > from urllib import urlencode > from django.contrib.auth.models import User > > class ContactManipulator(forms.Manipulator): > def __init__(self): > self.fields = [ > forms.TextField('name', is_required=True), > forms.EmailField('from_address', is_required=True), > forms.LargeTextField('message', is_required=True), > ] > > def save(self, new_data, to): > mail.send_mail("Gretsch Pages contact form message", > new_data["message"], > new_data["from_address"], > str(to), > fail_silently = False > ) > > return "done/" > > def contact(request, slug=""): > if slug=="": > to = "[EMAIL PROTECTED]" > else: > to = User.objects.get(username=slug).email > return form_helper(request, to, ContactManipulator(), > "contact/form.html") > > > def form_helper(request, to, manipulator, template): > if request.POST: > new_data = request.POST.copy() > errors = manipulator.get_validation_errors(new_data) > if not errors: > manipulator.do_html2python(new_data) > redirect_url = manipulator.save(new_data, to) > return HttpResponseRedirect(redirect_url) > else: > errors = new_data = {} > context = {'form' : forms.FormWrapper(manipulator, new_data, > errors)} > return render_to_response(template, context) > > Any ideas? > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---