protected function _smtpSend($data, $checkCode = '250')
    {
        $this->_lastResponse = [];

        if ($data !== null) {
            $this->_socket->write($data . "\r\n");
        }

        $timeout = $this->_config['timeout'];

        while ($checkCode !== false) {
            $response = '';
            $startTime = time();
            while (substr($response, -2) !== "\r\n" && ((time() - $startTime) < $timeout)) {
                $bytes = $this->_socket->read();
                if ($bytes === false || $bytes === null) {
                    break;
                }
                $response .= $bytes;
            }
            if (substr($response, -2) !== "\r\n") {
                throw new SocketException('SMTP timeout.');
            }
            $responseLines = explode("\r\n", rtrim($response, "\r\n"));
            $response = end($responseLines);

            $this->_bufferResponseLines($responseLines);

            if (preg_match('/^(' . $checkCode . ')(.)/', $response, $code)) {
                if ($code[2] === '-') {
                    continue;
                }

                return $code[1];
            }
            throw new SocketException(sprintf('SMTP Error: %s', $response));
        }
    }