Commits

Peter Wright committed 3b69f61 Merge

Merged jesumer fork - enabled text/html activation email.

Comments (0)

Files changed (1)

registration/models.py

 
 from django.conf import settings
 from django.contrib.auth.models import User
+from django.core.mail import EmailMultiAlternatives
 from django.db import models
 from django.db import transaction
 from django.template.loader import render_to_string
     def send_activation_email(self, site,
                               extra_context=None,
                               subject_template='registration/activation_email_subject.txt',
-                              body_template='registration/activation_email.txt'):
+                              body_template='registration/activation_email.txt',
+                              html_body_template='registration/activation_email.html'):
         """
         Send an activation email to the user associated with this
         ``RegistrationProfile``.
         # Email subject *must not* contain newlines
         subject = ''.join(subject.splitlines())
         
-        message = render_to_string(body_template, ctx_dict)
+        text_content = render_to_string(body_template, ctx_dict)
+        html_content = render_to_string(html_body_template, ctx_dict)
         
-        self.user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)
+        subject, from_email, to = subject, settings.DEFAULT_FROM_EMAIL, self.user.email
+        msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
+        msg.attach_alternative(html_content, "text/html")
+        msg.send()