It looks like the problem isn't with send_mail, its the save override
on the form, the is_active = False isn't setting that option in the DB
either, so it is skipping over the save options. Here they are again:

forms.py:
class RegisterForm(UserCreationForm):
    email = forms.EmailField(label="E-Email")

    class Meta:
        model = User
        fields = ("username", "email")

    def clean_email(self):
        email = self.cleaned_data["email"]

        try:
            User.objects.get(email=email)
        except User.DoesNotExist:
            return email

        raise forms.ValidationError("A user with that email address
already exists.")

        def save(self):
            user = super(RegisterForm, self).save(commit=False)
            send_activation(user)
            user.is_active = False
            user.save()

and the view:

def register(request):
    if request.method == 'POST':
        form = RegisterForm(request.POST)
        if form.is_valid():
            new_user = form.save()

            return HttpResponseRedirect("/obits/")
    else:
        form = RegisterForm()

    return render_to_response("obits/register.html", {'form': form })

So, the username and all of that are saving by the user.is_active and
send_mail are getting skipped


On May 19, 4:37 am, Nuno Maltez <nuno.li...@gmail.com> wrote:
> Anything it the mail server's logs? Any trace of your app trying tosendthe 
> message? Any errors?
>
> Nuno
>
>
>
> On Tue, May 18, 2010 at 11:42 PM, Nick <nickt...@gmail.com> wrote:
> > Actually, I've fixed the problem with send_activation. If i go via the
> > form it still doesn't trigger the email.
>
> > On May 18, 5:19 pm, Nick <nickt...@gmail.com> wrote:
> >> I get the same results.
>
> >> I dropped into the shell and tried it out
>
> >> >>> user = User(username="nick", email="t...@test.com")
> >> >>> send_activation(user)
>
> >> 1
>
> >> I think the 1 means that it passed but I don't get any emails sent
>
> >> On May 18, 5:08 pm, "ge...@aquarianhouse.com"
>
> >> <ge...@aquarianhouse.com> wrote:
> >> > what happens if you set fail_silently to True?
>
> >> > On May 19, 12:05 am, Nick <nickt...@gmail.com> wrote:
>
> >> > > I am having an issue with an authentication app I am writing. The app
> >> > > saves the form appropriately but doesn'tsendthe confirmation email.
> >> > > I am using the same email_host settings as with other application that
> >> > >sendemail messages but with no results. Here is the process.
>
> >> > > First a form processes the information:
>
> >> > > from django.contrib.auth.forms import UserCreationForm
> >> > > from django import forms
> >> > > from django.contrib.auth.models import User
> >> > > from activate import send_activation
>
> >> > > class RegisterForm(UserCreationForm):
> >> > >     email = forms.EmailField(label="E-Email")
>
> >> > >     class Meta:
> >> > >         model = User
> >> > >         fields = ("username", "email")
>
> >> > >     def clean_email(self):
> >> > >         email = self.cleaned_data["email"]
>
> >> > >         try:
> >> > >             User.objects.get(email=email)
> >> > >         except User.DoesNotExist:
> >> > >             return email
>
> >> > >         raise forms.ValidationError("A user with that email address
> >> > > already exists.")
>
> >> > >         def save(self):
> >> > >             user = super(RegisterForm, self).save(commit=False)
> >> > >             send_activation(user)
> >> > >             user.is_active = False
> >> > >             user.save()
>
> >> > > the activate.py file:
>
> >> > > from django.core.mail import send_mail
> >> > > from hashlib import md5
> >> > > from django.template import loader, Context
> >> > > from Obits.settings import BASE_URL as base_url
>
> >> > > def send_activation(user):
> >> > >     code = md5(user.username).hexdigest()
> >> > >     url = "%sactivate/?user=%s&code=%s" % (base_url, user.username,
> >> > > code)
> >> > >     template = loader.get_template('obits/eactivate.html')
> >> > >     context = ({
> >> > >          'username': user.username,
> >> > >          'url': url,
> >> > >      })
> >> > >     send_mail('Activate account at super site', 'this is a test',
> >> > > 'myem...@mydomain.com, [user.email], fail_silently=False)
>
> >> > > The form saves to the DB, it hits all of the conditions but fails to
> >> > >sendan email. I can't get any error messages so I'm really at a loss.
>
> >> > > --
> >> > > You received this message because you are subscribed to the Google 
> >> > > Groups "Django users" group.
> >> > > To post to this group,sendemail to django-us...@googlegroups.com.
> >> > > To unsubscribe from this group,sendemail to 
> >> > > django-users+unsubscr...@googlegroups.com.
> >> > > For more options, visit this group 
> >> > > athttp://groups.google.com/group/django-users?hl=en.
>
> >> > --
> >> > You received this message because you are subscribed to the Google 
> >> > Groups "Django users" group.
> >> > To post to this group,sendemail to django-us...@googlegroups.com.
> >> > To unsubscribe from this group,sendemail to 
> >> > django-users+unsubscr...@googlegroups.com.
> >> > For more options, visit this group 
> >> > athttp://groups.google.com/group/django-users?hl=en.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups 
> >> "Django users" group.
> >> To post to this group,sendemail to django-us...@googlegroups.com.
> >> To unsubscribe from this group,sendemail to 
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group 
> >> athttp://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group,sendemail to django-us...@googlegroups.com.
> > To unsubscribe from this group,sendemail to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group,sendemail to django-us...@googlegroups.com.
> To unsubscribe from this group,sendemail to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to