class_docstr: This hook connects to a mail server by using the smtp protocol.
  
  .. note:: Please call this Hook as context manager via `with`
      to automatically open and close the connection to the mail server.
  
  :param smtp_conn_id: The :ref:`smtp connection id <howto/connection:smtp>`
      that contains the information used to authenticate the client.
docstr: Build a MIME message that can be used to send an email and returns a full list of recipients.
  
  :param mail_from: Email address to set as the email's "From" field.
  :param to: A string or iterable of strings containing email addresses
      to set as the email's "To" field.
  :param subject: The subject of the email.
  :param html_content: The content of the email in HTML format.
  :param files: A list of paths to files to be attached to the email.
  :param cc: A string or iterable of strings containing email addresses
      to set as the email's "CC" field.
  :param bcc: A string or iterable of strings containing email addresses
      to set as the email's "BCC" field.
  :param mime_subtype: The subtype of the MIME message. Default: "mixed".
  :param mime_charset: The charset of the email. Default: "utf-8".
  :param custom_headers: Additional headers to add to the MIME message.
      No validations are run on these values, and they should be able to be encoded.
  :return: A tuple containing the email as a MIMEMultipart object and
      a list of recipient email addresses.
docstr_tok: ["Build","a","MIME","message","that","can","be","used","to","send","an","email","and","returns","a","full","list","of","recipients",".",":","param","mail_from",":","Email","address","to","set","as","the","email","'s","``","From","''","field",".",":","param","to",":","A","string","or","iterable","of","strings","containing","email","addresses","to","set","as","the","email","'s","``","To","''","field",".",":","param","subject",":","The","subject","of","the","email",".",":","param","html_content",":","The","content","of","the","email","in","HTML","format",".",":","param","files",":","A","list","of","paths","to","files","to","be","attached","to","the","email",".",":","param","cc",":","A","string","or","iterable","of","strings","containing","email","addresses","to","set","as","the","email","'s","``","CC","''","field",".",":","param","bcc",":","A","string","or","iterable","of","strings","containing","email","addresses","to","set","as","the","email","'s","``","BCC","''","field",".",":","param","mime_subtype",":","The","subtype","of","the","MIME","message",".","Default",":","``","mixed","''",".",":","param","mime_charset",":","The","charset","of","the","email",".","Default",":","``","utf-8","''",".",":","param","custom_headers",":","Additional","headers","to","add","to","the","MIME","message",".","No","validations","are","run","on","these","values",",","and","they","should","be","able","to","be","encoded",".",":","return",":","A","tuple","containing","the","email","as","a","MIMEMultipart","object","and","a","list","of","recipient","email","addresses","."]
code: def _build_mime_message(
      self,
      mail_from: str | None,
      to: str | Iterable[str],
      subject: str,
      html_content: str,
      files: list[str] | None = None,
      cc: str | Iterable[str] | None = None,
      bcc: str | Iterable[str] | None = None,
      mime_subtype: str = "mixed",
      mime_charset: str = "utf-8",
      custom_headers: dict[str, Any] | None = None,
  ) -> tuple[MIMEMultipart, list[str]]:
      """
      Build a MIME message that can be used to send an email and returns a full list of recipients.
  
      :param mail_from: Email address to set as the email's "From" field.
      :param to: A string or iterable of strings containing email addresses
          to set as the email's "To" field.
      :param subject: The subject of the email.
      :param html_content: The content of the email in HTML format.
      :param files: A list of paths to files to be attached to the email.
      :param cc: A string or iterable of strings containing email addresses
          to set as the email's "CC" field.
      :param bcc: A string or iterable of strings containing email addresses
          to set as the email's "BCC" field.
      :param mime_subtype: The subtype of the MIME message. Default: "mixed".
      :param mime_charset: The charset of the email. Default: "utf-8".
      :param custom_headers: Additional headers to add to the MIME message.
          No validations are run on these values, and they should be able to be encoded.
      :return: A tuple containing the email as a MIMEMultipart object and
          a list of recipient email addresses.
      """
      to = self._get_email_address_list(to)
  
      msg = MIMEMultipart(mime_subtype)
      msg["Subject"] = subject
      msg["From"] = mail_from
      msg["To"] = ", ".join(to)
      recipients = to
      if cc:
          cc = self._get_email_address_list(cc)
          msg["CC"] = ", ".join(cc)
          recipients += cc
  
      if bcc:
          # don't add bcc in header
          bcc = self._get_email_address_list(bcc)
          recipients += bcc
  
      msg["Date"] = formatdate(localtime=True)
      mime_text = MIMEText(html_content, "html", mime_charset)
      msg.attach(mime_text)
  
      for fname in files or []:
          basename = os.path.basename(fname)
          with open(fname, "rb") as file:
              part = MIMEApplication(file.read(), Name=basename)
              part[
                  "Content-Disposition"
              ] = f'attachment; filename="{basename}"'
              part["Content-ID"] = f"<{basename}>"
              msg.attach(part)
  
      if custom_headers:
          for header_key, header_value in custom_headers.items():
              msg[header_key] = header_value
  
      return msg, recipients
  
imports: from __future__ import annotations
  import collections.abc
  import os
  import re
  import smtplib
  import ssl
  from email.mime.application import MIMEApplication
  from email.mime.multipart import MIMEMultipart
  from email.mime.text import MIMEText
  from email.utils import formatdate
  from typing import TYPE_CHECKING, Any, Iterable
  from airflow.exceptions import AirflowException, AirflowNotFoundException
  from airflow.hooks.base import BaseHook
label_desc: Use image node_id 9 for calling the SmtpHook obj's underlying member method code with example usage: obj._build_mime_message(mail_from, to, subject, html_content, files, cc, bcc, mime_subtype, mime_charset, custom_headers) and returns: msg,  recipients