from django.core.mail import send_mail as django_send_email
from django.conf import settings


def send_mail(subject, message, to_emails, from_email=settings.DEFAULT_FROM_EMAIL, fail_silently=True):
    """Send email using Django's send_email function but setting a number of defaults and adding a
    prefix in the subject."""
    if not subject.startswith(settings.EMAIL_SUBJECT_PREFIX):
        subject = settings.EMAIL_SUBJECT_PREFIX + subject
    if type(to_emails) is not list and type(to_emails) is not tuple:
        to_emails = (to_emails, )
    django_send_email(subject, message, from_email, to_emails, fail_silently)

@@ -90,91 +90,204 @@
 ngs%0A
-%0A%0Adef send_mail(subject, message, to_emails, from_email=settings.DEFAULT_FROM_EMAIL
+from django.template.loader import render_to_string%0A%0A%0Adef send_mail(to_emails, from_email=settings.DEFAULT_FROM_EMAIL, subject='No subject',%0A              message=None, template=None, context=None
 , fa
@@ -430,16 +430,71 @@
 subject.
+ It also renders a template with a context if provided.
 %22%22%22%0A    
@@ -609,16 +609,123 @@
 subject%0A
+    if template is not None and context is not None:%0A        message = render_to_string(template, context)%0A
     if t

Improve send_mail wrapper and add support for rendering templates