Calls :meth:`SMTP.ehlo` and/or :meth:`SMTP.helo` if needed.

        If there hasn't been any previous *EHLO* or *HELO* command this
        session, tries to initiate the session. *EHLO* is tried first.

        Raises:
            ConnectionResetError: If the connection with the server is
                unexpectedely lost.
            SMTPCommandFailedError: If the server refuses our EHLO/HELO
                greeting.

async def ehlo_or_helo_if_needed(self):
        """
        Calls :meth:`SMTP.ehlo` and/or :meth:`SMTP.helo` if needed.

        If there hasn't been any previous *EHLO* or *HELO* command this
        session, tries to initiate the session. *EHLO* is tried first.

        Raises:
            ConnectionResetError: If the connection with the server is
                unexpectedely lost.
            SMTPCommandFailedError: If the server refuses our EHLO/HELO
                greeting.
        """
        no_helo = self.last_helo_response == (None, None)
        no_ehlo = self.last_ehlo_response == (None, None)

        if no_helo and no_ehlo:
            try:
                # First we try EHLO:
                await self.ehlo()
            except SMTPCommandFailedError:
                # EHLO failed, let's try HELO:
                await self.helo()