def send_templated_email(subject, template_name, context,
                         recipients, sender=None, bcc=None,
                         fail_silently=True, files=None):

    c = Context(context)
    if not sender:
        sender = settings.DEFAULT_FROM_EMAIL

    template = loader.get_template(template_name)

    text_part = strip_tags(template.render(c))
    html_part = template.render(c)

    if type(recipients) == str:
        if recipients.find(','):
            recipients = recipients.split(',')
    elif type(recipients) != list:
        recipients = [recipients, ]

    msg = EmailMultiAlternatives(subject,
                                 text_part,
                                 sender,
                                 recipients,
                                 bcc=bcc)
    msg.attach_alternative(html_part, "text/html")

    if files:
        if type(files) != list:
            files = [files, ]

        for file in files:
            msg.attach_file(file)

    return msg.send(fail_silently)
send_templated_mail() is a wrapper around Django's e-mail routines that
dataset/ETHPy150Open django-leonardo/django-leonardo/leonardo/utils/email.py/send_templated_email