code: def send_email(self, recipients, subject, body, attachments=None):
          
  
          recipient_pairs = map(self.parse_email, recipients)
          template_context = {
              "recipients": "\n".join(
                  map(lambda p: formataddr(p), recipient_pairs))
          }
  
          body_template = Template(safe_unicode(body)).safe_substitute(
              **template_context)
  
          _preamble = "This is a multi-part message in MIME format.\n"
          _from = formataddr((self.email_from_name, self.email_from_address))
          _subject = Header(s=safe_unicode(subject), charset="utf8")
          _body = MIMEText(body_template, _subtype="plain", _charset="utf8")
  
          # Create the enclosing message
          mime_msg = MIMEMultipart()
          mime_msg.preamble = _preamble
          mime_msg["Subject"] = _subject
          mime_msg["From"] = _from
          mime_msg.attach(_body)
  
          # Attach attachments
          for attachment in attachments:
              mime_msg.attach(attachment)
  
          success = []
          # Send one email per recipient
          for pair in recipient_pairs:
              # N.B.: Headers are added additive, so we need to remove any
              #       existing "To" headers
              # No KeyError is raised if the key does not exist.
              # https://docs.python.org/2/library/email.message.html#email.message.Message.__delitem__
              del mime_msg["To"]
  
              # N.B. we use just the email here to prevent this Postfix Error:
              # Recipient address rejected: User unknown in local recipient table
              mime_msg["To"] = pair[1]
              msg_string = mime_msg.as_string()
              sent = self.send(msg_string)
              if not sent:
                  logger.error("Could not send email to {}".format(pair))
              success.append(sent)
  
          if not all(success):
              return False
          return True
docs: Prepare and send email to the recipients
  
          :param recipients: a list of email or name,email strings
          :param subject: the email subject
          :param body: the email body
          :param attachments: list of email attachments
          :returns: True if all emails were sent, else false