Send it out and return the response

@param *string  $command The raw SMTP command
@param int|null $code    The command code

@return string|false
359407
protected function call($command, $code = null)
    {
        if (!$this->push($command)) {
            return false;
        }

        $receive = $this->receive();

        $args = func_get_args();
        if (count($args) > 1) {
            for ($i = 1; $i < count($args); $i++) {
                if (strpos($receive, (string)$args[$i]) === 0) {
                    return true;
                }
            }

            return false;
        }

        return $receive;
    }
592368
public function client_send($data, $command = '')
    {
        //If SMTP transcripts are left enabled, or debug output is posted online
        //it can leak credentials, so hide credentials in all but lowest level
        if (self::DEBUG_LOWLEVEL > $this->do_debug and
            in_array($command, ['User & Password', 'Username', 'Password'], true)) {
            $this->edebug('CLIENT -> SERVER: <credentials hidden>', self::DEBUG_CLIENT);
        } else {
            $this->edebug('CLIENT -> SERVER: ' . $data, self::DEBUG_CLIENT);
        }
        set_error_handler([$this, 'errorHandler']);
        $result = fwrite($this->smtp_conn, $data);
        restore_error_handler();

        return $result;
    }
89174
public static function getCommand(): Command
    {
        if (is_null(self::$exec)) {
            self::$exec = new Command();
        }
        return self::$exec;
    }
458650
def SendCommand(self, command, arg=None):
        
        if arg is not None:
            if not isinstance(arg, bytes):
                arg = arg.encode('utf8')
            command = b'%s:%s' % (command, arg)

        self._Write(io.BytesIO(command), len(command))
927542
public static function codeResponse($code,$message)
    {
        $code = intval($code);

        foreach(self::$results as $v) {
            if ($v['message'] == $message && $v['code'] == $code)
                return $v;
        }

        return null;
    }
1302193
private function send(AbstractCommand $command)
    {
        $cmdId = $this->generateId();
        $this->commands->add($cmdId, $command);
        if (!$command->getClient()->send($this->serializeCommand($command, $cmdId))) {
            throw new \RuntimeException(sprintf('Fail run command "%s".', $command->getCommandName()));
        }
    }
129371
protected function execute($command)
    {
        $status = null;
        $result = array();
        exec($command, $result, $status);
        return !$status ? $result : null;
    }
902057
public function send($method,$arg1="",$arg2="") {

        // if we have a string, send it as well
        if($arg1 != "" && $arg2 != "")
        {
            $command = "$method \"$arg1\" \"$arg2\"";
        }
        elseif($arg1 != "") {
            $command = "$method \"$arg1\"";
        }
        else {
            $command = $method;
        }


        fputs($this->fp,"$command\n"); //Do desired action!
        $c = 0;
        while(!feof($this->fp)) {
            $got =  fgets($this->fp,1024);
            if(strncmp("OK",$got,strlen("OK"))==0)
                break;
            if(strncmp("ACK",$got,strlen("ACK"))==0)
                break;

            $ret[$c]=$got;
            $c++;
        }

        $sentResponse = array(
            "response" => $this->response,
            "got" => $got,
            "ret" => $ret
        );
        return $sentResponse;

    }
1159864
public function post($command, $params = null, $postcontenttype = 'application/json')
    {
        $url = $command;

        $headers = array('Content-Type' => $postcontenttype);

        $content = $params;
        if ($postcontenttype == 'application/json') {
            $content = json_encode($params);
        }

        try {
            $response = $this->client->post($url, ['headers' => $headers, 'body' => $content]);
        } catch (\Exception $e) {
            return null;
        }
        $this->checkError($response, $url);

        return $response->getBody();
    }
698289
protected function dispatch(Command $command)
    {
        // re-connect if we have timed out
        if ($this->isTimedOut() === true) {
            $this->close();
            $this->connect();
        }

        // construct message
        $message = $command->getCommand() . "\r\n";

        if (($data = $command->getData()) !== false) {
            $message .= $data . "\r\n";
        }

        // write to stream
        if ($this->stream->write($message) === false) {
            throw new Exception(
                'Error writing data to the server.',
                Exception::SERVER_WRITE
            );
        }

        // read response from stream
        $response = $this->stream->readLine();

        // validate against common errors
        $this->validateResponse($response);

        $data = null;

        if ($command->returnsData()) {
            $bytes = preg_replace('/^.*\b(\d+)$/', '$1', $response);
            $data = $this->stream->read($bytes);
        }

        return $command->parseResponse($response, $data, $this);
    }
254590
public void send(Command command) {
    logger.finest(command.toString());
    byte[] payload = command.toByteArray();
    int totalSize = payload.length + 1; // increment 1 for message type

    ByteBuffer outMessageSize = encodeMessageSize(totalSize);

    // create the message
    ByteBuffer buffer = ByteBuffer.allocateDirect(prefix.length
                                                  + outMessageSize.position() + 1 + payload.length);
    buffer.put(prefix, 0, prefix.length);
    outMessageSize.flip();
    buffer.put(outMessageSize);
    buffer.put((byte) 1);
    buffer.put(payload);

    // Log what is being sent.
    logger.finest("SEND: " + command);

    requests.add(buffer);
    monitor.modify(socketChannel, this, SelectionKey.OP_READ | SelectionKey.OP_WRITE);
  }
780743
public function rawcommand($command)
    {
        if (preg_match('/(.+)[\n]$/', $command)) {
            $this->socket->send($command);
        } else {
            $this->socket->send($command.PHP_EOL);
        }
    }
202355
private function getEmailResponse($command, $parameters = array(), $first = false)
    {
        //send out the command
        if (!$this->send($command, $parameters)) {
            return false;
        }

        $messageId  = $uniqueId = $count = 0;
        $emails     = $email = array();
        $start      = time();

        //while there is no hang
        while (time() < ($start + self::TIMEOUT)) {
            //get a response line
            $line = str_replace("\n", '', $this->getLine());

            //if the line starts with a fetch
            //it means it's the end of getting an email
            if (strpos($line, 'FETCH') !== false && strpos($line, 'TAG'.$this->tag) === false) {
                //if there is email data
                if (!empty($email)) {
                    //create the email format and add it to emails
                    $emails[$uniqueId] = $this->getEmailFormat($email, $uniqueId, $flags);

                    //if all we want is the first one
                    if ($first) {
                        //just return this
                        return $emails[$uniqueId];
                    }

                    //make email data empty again
                    $email = array();
                }

                //if just okay
                if (strpos($line, 'OK') !== false) {
                    //then skip the rest
                    continue;
                }

                //if it's not just ok
                //it will contain the message id and the unique id and flags
                $flags = array();
                if (strpos($line, '\Answered') !== false) {
                    $flags[] = 'answered';
                }

                if (strpos($line, '\Flagged') !== false) {
                    $flags[] = 'flagged';
                }

                if (strpos($line, '\Deleted') !== false) {
                    $flags[] = 'deleted';
                }

                if (strpos($line, '\Seen') !== false) {
                    $flags[] = 'seen';
                }

                if (strpos($line, '\Draft') !== false) {
                    $flags[] = 'draft';
                }

                $findUid = explode(' ', $line);
                foreach ($findUid as $i => $uid) {
                    if (is_numeric($uid)) {
                        $uniqueId = $uid;
                    }
                    if (strpos(strtolower($uid), 'uid') !== false) {
                        $uniqueId = $findUid[$i+1];
                        break;
                    }
                }

                //skip the rest
                continue;
            }

            //if there is a tag it means we are at the end
            if (strpos($line, 'TAG'.$this->tag) !== false) {
                //if email details are not empty and the last line is just a )
                if (!empty($email) && strpos(trim($email[count($email) -1]), ')') === 0) {
                    //take it out because that is not part of the details
                    array_pop($email);
                }

                //if there is email data
                if (!empty($email)) {
                    //create the email format and add it to emails
                    $emails[$uniqueId] = $this->getEmailFormat($email, $uniqueId, $flags);

                    //if all we want is the first one
                    if ($first) {
                        //just return this
                        return $emails[$uniqueId];
                    }
                }

                //break out of this loop
                break;
            }

            //so at this point we are getting raw data
            //capture this data in email details
            $email[] = $line;
        }

        return $emails;
    }
37571
public function execute($command, $prompt = null)
    {
        if (!$this->socket) {
            throw new TelnetException('attempt to execute without a connection - call connect first');
        }

        $this->write($command);
        return $this->getResponse($prompt);
    }
59535
public function sendHttpCode($code = null)
    {
        if (func_num_args() == 0) {
            return $this->sendHttpCode;
        }

        if (!$code) {
            return $this->sendHttpCode = false;
        }

        if ($code === true) {
            $code = 500;
        }

        if ($code < 400 || 600 <= $code) {
            throw new InvalidArgumentException(
                 "Invalid status code '$code', must be 4xx or 5xx"
            );
        }

        return $this->sendHttpCode = $code;
    }
992472
public function aExecuteCommandTo($command) {
        $this->restartKernel();
        $kernel = $this->getKernel();

        $application = new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel);
        $application->setAutoExit(false);

        $exploded = explode(" ", $command);

        $commandsParams = [
        ];
        foreach ($exploded as $value) {
            if (!isset($commandsParams["command"])) {
                $commandsParams["command"] = $value;
            } else {
                $e2 = explode("=", $value);
//                var_dump($e2);
                if (count($e2) == 1) {
                    $commandsParams[] = $e2[0];
                } else if (count($e2) == 2) {
                    $commandsParams[$e2[0]] = $e2[1];
                }
            }
        }
        foreach ($commandsParams as $key => $value) {
            $commandsParams[$key] = $value;
        }
        $input = new \Symfony\Component\Console\Input\ArrayInput($commandsParams);
        if ($output === null) {
            $output = new \Symfony\Component\Console\Output\ConsoleOutput();
        }
        $application->run($input, $output);
//         $content = $output->fetch();
    }
184027
public function command($cmd, $q = '', $cb = null)
    {
        if ($this->phase !== self::PHASE_HANDSHAKED) {
            return false;
        }

        $this->onResponse->push($cb);
        $this->seq = 0;
        $this->sendPacket(chr($cmd) . $q);

        return true;
    }