Commits

Anonymous committed bdcdfe4

added support for html email

Comments (0)

Files changed (1)

registration/models.py

 from django.template.loader import render_to_string
 from django.utils.hashcompat import sha_constructor
 from django.utils.translation import ugettext_lazy as _
-
+from django.core.mail import EmailMultiAlternatives
 
 SHA1_RE = re.compile('^[a-f0-9]{40}$')
 
                     'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS,
                     'site': site}
         subject = render_to_string('registration/activation_email_subject.txt',
-                                   ctx_dict)
-        # Email subject *must not* contain newlines
+                                    ctx_dict )
         subject = ''.join(subject.splitlines())
         
-        message = render_to_string('registration/activation_email.txt',
+        text_message = render_to_string('registration/activation_email.txt',
                                    ctx_dict)
+        html_message = render_to_string('registration/activation_email.html',
+                                   ctx_dict)                                   
         
-        self.user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)
+        msg = EmailMultiAlternatives(subject, text_message, settings.DEFAULT_FROM_EMAIL, [user.email])
+        msg.attach_alternative(html_message, "text/html")
+        msg.send()