X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fforms.py;h=cf3e172ab0e0ded57a403715d8171873049014a3;hb=d7e386318945be3df497f1f6b2ed78d00e9f0c37;hp=61ffb8608188e71af68573766d01e4b3fb38bc91;hpb=7a2adbf990df5b497411f51e51d26aae290c70f1;p=unfold.git diff --git a/portal/forms.py b/portal/forms.py index 61ffb860..cf3e172a 100644 --- a/portal/forms.py +++ b/portal/forms.py @@ -170,28 +170,31 @@ class PasswordResetForm(forms.Form): Generates a one-use only link for resetting password and sends to the user. """ - from django.core.mail import send_mail - for user in self.users_cache: - if not domain_override: - current_site = get_current_site(request) - site_name = current_site.name - domain = current_site.domain - else: - site_name = domain = domain_override - c = { - 'email': user.email, - 'domain': domain, - 'site_name': site_name, - 'uid': int_to_base36(user.pk), - 'user': user, - 'token': token_generator.make_token(user), - 'protocol': use_https and 'https' or 'http', - } - subject = loader.render_to_string(subject_template_name, c) - # Email subject *must not* contain newlines - subject = ''.join(subject.splitlines()) - email = loader.render_to_string(email_template_name, c) - send_mail(subject, email, from_email, [user.email]) + from django.core.mail import send_mail,EmailMultiAlternatives + try: + for user in self.users_cache: + if not domain_override: + current_site = get_current_site(request) + site_name = current_site.name + domain = current_site.domain + else: + site_name = domain = domain_override + c = { + 'email': user.email, + 'domain': domain, + 'site_name': site_name, + 'uid': int_to_base36(user.pk), + 'user': user, + 'token': token_generator.make_token(user), + 'protocol': use_https and 'https' or 'http', + } + subject = loader.render_to_string(subject_template_name, c) + # Email subject *must not* contain newlines + subject = ''.join(subject.splitlines()) + email = loader.render_to_string(email_template_name, c) + send_mail(subject, email, from_email, [user.email]) + except Exception, e: + print "Failed to send email, please check the mail templates and the SMTP configuration of your server" class SetPasswordForm(forms.Form):