class_docstr: This hook connects to a mail server by using the imap protocol.
  
  .. note:: Please call this Hook as context manager via `with`
      to automatically open and close the connection to the mail server.
  
  :param imap_conn_id: The :ref:`imap connection id <howto/connection:imap>`
      that contains the information used to authenticate the client.
code: def _build_client(
      self, conn: Connection
  ) -> imaplib.IMAP4_SSL | imaplib.IMAP4:
      mail_client: imaplib.IMAP4_SSL | imaplib.IMAP4
      use_ssl = conn.extra_dejson.get("use_ssl", True)
      if use_ssl:
          from airflow.configuration import conf
  
          extra_ssl_context = conn.extra_dejson.get("ssl_context", None)
          if extra_ssl_context:
              ssl_context_string = extra_ssl_context
          else:
              ssl_context_string = conf.get(
                  "imap", "SSL_CONTEXT", fallback=None
              )
          if ssl_context_string is None:
              ssl_context_string = conf.get(
                  "email", "SSL_CONTEXT", fallback=None
              )
          if ssl_context_string is None:
              ssl_context_string = "default"
          if ssl_context_string == "default":
              ssl_context = ssl.create_default_context()
          elif ssl_context_string == "none":
              ssl_context = None
          else:
              raise RuntimeError(
                  f"The email.ssl_context configuration variable must "
                  f"be set to 'default' or 'none' and is '{ssl_context_string}'."
              )
          if conn.port:
              mail_client = imaplib.IMAP4_SSL(
                  conn.host, conn.port, ssl_context=ssl_context
              )
          else:
              mail_client = imaplib.IMAP4_SSL(
                  conn.host, ssl_context=ssl_context
              )
      else:
          if conn.port:
              mail_client = imaplib.IMAP4(conn.host, conn.port)
          else:
              mail_client = imaplib.IMAP4(conn.host)
  
      return mail_client
  
imports: from __future__ import annotations
  import email
  import imaplib
  import os
  import re
  import ssl
  from typing import TYPE_CHECKING, Any, Iterable
  from airflow.exceptions import AirflowException
  from airflow.hooks.base import BaseHook
  from airflow.utils.log.logging_mixin import LoggingMixin
label_desc: Use image node_id 5 for calling the ImapHook obj's underlying member method code with example usage: obj._build_client(conn) and returns: mail_client