code: def send_mail_template(subject, template, addr_from, addr_to, context=None,
                         attachments=None, fail_silently=None, addr_bcc=None,
                         headers=None):
      
      if context is None:
          context = {}
      if attachments is None:
          attachments = []
      if fail_silently is None:
          fail_silently = settings.EMAIL_FAIL_SILENTLY
      # Add template accessible settings from yacms to the context
      # (normally added by a context processor for HTTP requests).
      context.update(context_settings())
      # Allow for a single address to be passed in.
      # Python 3 strings have an __iter__ method, so the following hack
      # doesn't work: if not hasattr(addr_to, "__iter__"):
      if isinstance(addr_to, str) or isinstance(addr_to, bytes):
          addr_to = [addr_to]
      if addr_bcc is not None and (isinstance(addr_bcc, str) or
                                   isinstance(addr_bcc, bytes)):
          addr_bcc = [addr_bcc]
      # Loads a template passing in vars as context.
      render = lambda type: loader.get_template("%s.%s" %
                            (template, type)).render(Context(context))
      # Create and send email.
      msg = EmailMultiAlternatives(subject, render("txt"),
                                   addr_from, addr_to, addr_bcc,
                                   headers=headers)
      msg.attach_alternative(render("html"), "text/html")
      for attachment in attachments:
          msg.attach(*attachment)
      msg.send(fail_silently=fail_silently)
docs: Send email rendering text and html versions for the specified
      template name using the context dictionary passed in.