code: async def starttls(
          self,
          tls_context: ssl.SSLContext,
          server_hostname: str = None,
          timeout: NumType = None,
      ) -> StartTLSResponse:
          
          if self._stream_reader is None or self._stream_writer is None:
              raise SMTPServerDisconnected("Client not connected")
  
          response = await self.execute_command(b"STARTTLS", timeout=timeout)
  
          if response.code != SMTPStatus.ready:
              raise SMTPResponseException(response.code, response.message)
  
          await self._drain_writer(timeout)
  
          waiter = asyncio.Future(loop=self._loop)  # type: asyncio.Future
  
          tls_protocol = self.upgrade_transport(
              tls_context, server_hostname=server_hostname, waiter=waiter
          )
  
          try:
              await asyncio.wait_for(waiter, timeout=timeout, loop=self._loop)
          except asyncio.TimeoutError as exc:
              raise SMTPTimeoutError(str(exc))
  
          return response, tls_protocol
docs: Puts the connection to the SMTP server into TLS mode.