Send a short message using the JetSms services.

@param  ShortMessage $shortMessage

@return JetSmsResponseInterface
350387
public function sendShortMessage(ShortMessage $shortMessage)
    {
        $payload = $this->generateSingleMessageBody($shortMessage);

        return new JetSmsXmlResponse($this->performCurlSession($payload));
    }
1149428
protected function sendNewsMsgToJsonString(WxSendNewsMsg $msg)
    {
        $itemArray  = $msg->getAllArticleItems();
        $itemStr    = '';
        foreach ($itemArray as $item) {
            $itemStr .= $this->sendNewsItemToJsonString($item) . ',';
        }

        $itemStr    = substr($itemStr, 0, -1);

        $formatStr = '{
                        "touser":"%s",
                        "msgtype":"%s",
                        "news":{
                            "articles": [
                             %s
                             ]
                        }
                    }';

        $result = sprintf($formatStr,   $msg->getToUserName(),
                                        $msg->getMsgType(),
                                        $itemStr
                            );

        return $result;
    }
1061859
public function send(\Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
    {
        $message->generateId();

        // Create a mbox-like header
        $mboxFrom = $this->getReversePath($message);
        $mboxDate = strftime('%c', $message->getDate()->getTimestamp());
        $messageString = sprintf('From %s %s', $mboxFrom, $mboxDate) . chr(10);

        // Add the complete mail inclusive headers
        $messageString .= $message->toString();
        $messageString .= chr(10) . chr(10);

        // Write the mbox file
        file_put_contents($this->mboxPathAndFilename, $messageString, FILE_APPEND | LOCK_EX);

        // Return every recipient as "delivered"
        return count((array)$message->getTo()) + count((array)$message->getCc()) + count((array)$message->getBcc());
    }
223030
public function push(ShortMessage $shortMessage)
    {
        if ($shortMessage->hasManyReceivers()) {
            throw new \LogicException(
                "Expected one receiver per short message, got many."
            );
        }

        $this->items[] = $shortMessage;

        return $this;
    }
19073
public function sendDelayedMessage(string $message, int $delay = 0)
    {
        $delay = max(0, $delay);
        $delay = min(900, $delay);
        $this->sqsClient->sendMessage([
            'DelaySeconds' => $delay,
            'MessageBody'  => $message,
            'QueueUrl'     => $this->queueUrl,
        ]);
    }
540962
public static function __($short, $chunks){
		$translated = self::_($short);
		foreach($chunks as $k=>$v){
			$translated = str_replace('%'.$k.'%', $v, $translated);
			}
		return $translated;
		}
718966
public function sendSMSResponse()
     {
        $response = new StdClass;
        $response->status = 'Sent';
        $response->message_id = $this->getValidMessageID();
        $response->sms_credits_used = 1;

        return $response;
     }
672909
function send($msg, $type = '')
    {
        // Set a short timeout to prevent long hangs
        stream_set_timeout($this->handle, 2);
        // Send message over connection
        fwrite($this->handle, $msg);

        // Check what type is required
        if ($type == 'array') {
            // If array loop and create array
            $response = array();
            $line_num = 0;
            while (!feof($this->handle)) {
                if (($response[$line_num] = fgets($this->handle, 4096)) === false) {
                    break;
                } else {
                    $line_num++;
                }
            }
            // Return response as array
            return $response;
        } elseif ($type == 'string') {
            // If string, loop and create string
            $response = '';
            while (!feof($this->handle)) {
                $response .= fgets($this->handle, 4096);
            }
            // Return response as string
            return $response;
        } else {
            // If anything else, return nothing but a true
            return true;
        }
    }
1148456
public function sendMessage(Message $msg)
    {
        if (is_callable($this->sendMessageFunction)) {
            call_user_func_array($this->sendMessageFunction, [$msg]);
        }
    }
1106173
public static String shortMessage( List<CompilerError> messages )
    {
        StringBuffer sb = new StringBuffer();

        sb.append( "Compilation failure" );

        if ( messages.size() == 1 )
        {
            sb.append( LS );

            CompilerError compilerError = (CompilerError) messages.get( 0 );

            sb.append( compilerError ).append( LS );
        }
        
        return sb.toString();
    }
1115031
private function sendGCMessage($mes, $text, $to)
    {
        $message=new AndroidMessage();
        $message->setMessage($text);
        $message->setData($mes);
        $message->setDeviceIdentifier($to);
        $message->setGCM(true);
//        $logger = $this->container->get('logger');
//        $logger->emerg(implode(',', $message->getData()));
        try {
            $response = $this->container->get('rms_push_notifications')->send($message);
        } catch (InvalidMessageTypeException $e) {
            throw $e;
        }

        return $response;
    }
417417
public function short($short) {
        $this->validated = false;
        if (!self::validateShort($short)) {
            throw new OptionConfigException('short option must be a single character: ' . $short);
        }
        $this->config[self::SHORT] = $short;
        return $this;
    }
875170
public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
    {
        $maxTransports = count($this->transports);
        $sent = 0;
        $this->lastUsedTransport = null;

        for ($i = 0; $i < $maxTransports
            && $transport = $this->getNextTransport(); ++$i) {
            try {
                if (!$transport->isStarted()) {
                    $transport->start();
                }

                if ($sent = $transport->send($message, $failedRecipients)) {
                    $this->lastUsedTransport = $transport;

                    return $sent;
                }
            } catch (Swift_TransportException $e) {
                $this->killCurrentTransport();
            }
        }

        if (0 == count($this->transports)) {
            throw new Swift_TransportException(
                'All Transports in FailoverTransport failed, or no Transports available'
                );
        }

        return $sent;
    }
789381
public function sendSmsToViettelWithMPSGateway()
    {
        $this->logger->debug(__FUNCTION__, 'Input Data Send SMS to Viettel MPS Gateway => ' . json_encode($this->inputData));
        $getConfig    = $this->getConfigData();
        $phone_number = $this->inputData['phone_number'];
        $msg          = $this->inputData['msg'];
        $alias        = $this->inputData['alias'];
        $params       = $this->inputData['params'];
        $this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
        $phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
        $content      = trim($msg);
        $url          = $this->wsConfig['api_link'];
        $username     = $this->wsConfig['username'];
        $password     = $this->wsConfig['password'];
        $shortcode    = $this->wsConfig['shortcode'];
        $timeout      = $this->wsConfig['timeout'];
        // Request Data với XML thuần
        $data_xml = '<?xml version="1.0"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://smsws/xsd"><soapenv:Header/><soapenv:Body><xsd:smsRequest><xsd:username>' . $username . '</xsd:username><xsd:password>' . $password . '</xsd:password><xsd:msisdn>' . $phone_number . '</xsd:msisdn><xsd:content>' . $content . '</xsd:content><xsd:shortcode>' . $shortcode . '</xsd:shortcode><xsd:alias>' . $alias . '</xsd:alias><xsd:params>' . $params . '</xsd:params></xsd:smsRequest></soapenv:Body></soapenv:Envelope>';
        $this->logger->info(__FUNCTION__, 'Send Request to URL ' . $url);
        $this->logger->info('Send Request Data ' . $data_xml);
        $requestSms = $this->requests->xmlRequest($url, $data_xml, $timeout); // Gửi Request SMS
        $this->logger->info(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
        $returnResult = $this->requests->xmlGetValue($requestSms, "<return>", "</return>"); // Display the result
        if ($returnResult == self::SEND_SMS_SUCCESS) {
            $result = array(
                'status'        => self::EXIT_SUCCESS,
                'msg'           => 'Gửi tin nhắn thành công',
                'data'          => array('returnResult' => $returnResult, 'requestResult' => $requestSms),
                'request_data'  => array('url' => $url, 'params' => $data_xml, 'method' => 'POST'),
                'response_data' => $requestSms,
                'content_data'  => array(
                    'phone_number' => $phone_number,
                    'msg'          => $msg,
                    'mo'           => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
                    'note'         => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
                    'subCode'      => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
                )
            );
        } else {
            if (array_key_exists($returnResult, $getConfig[self::CONFIG_KEY_SMS_GATEWAY_VIETTEL]['responseMap'])) {
                $result = array(
                    'status'        => self::EXIT_ERROR,
                    'msg'           => 'Gửi tin nhắn thất bại',
                    'data'          => array(
                        'returnResult'     => $returnResult,
                        'returnResultDesc' => Utils::strToEn($getConfig['responseMap'][$returnResult]),
                        'requestResult'    => $requestSms
                    ),
                    'request_data'  => array('url' => $url, 'params' => $data_xml, 'method' => 'POST'),
                    'response_data' => $requestSms,
                    'content_data'  => array(
                        'phone_number' => $phone_number,
                        'msg'          => $msg,
                        'mo'           => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
                        'note'         => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
                        'subCode'      => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
                    )
                );
            } else {
                $result = array(
                    'status'        => self::EXIT_CONFIG,
                    'msg'           => 'Lỗi hệ thống',
                    'data'          => array('returnResult' => $returnResult, 'requestResult' => $requestSms),
                    'request_data'  => array('url' => $url, 'params' => $data_xml, 'method' => 'POST'),
                    'response_data' => $requestSms,
                    'content_data'  => array(
                        'phone_number' => $phone_number,
                        'msg'          => $msg,
                        'mo'           => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
                        'note'         => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
                        'subCode'      => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
                    )
                );
            }
        }
        if ($this->responseIsObject) {
            $result = Utils::arrayToObject($result);
        }
        $this->sendSmsResult = $result;
        $this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));

        return $this;
    }
954639
public function getShortMessage($message)
    {
        static $hasMbString;

        if (null === $hasMbString) {
            $hasMbString = function_exists('mb_strlen');
        }

        $maxLength = 45;

        if ($hasMbString) {
            if (mb_strlen($message, 'UTF-8') > $maxLength) {
                $message = mb_substr($message, 0, $maxLength - 4, 'UTF-8') . ' ...';
            }
        } else {
            if (strlen($message) > $maxLength) {
                $message = substr($message, 0, $maxLength - 4) . ' ...';
            }
        }

        return $message;
    }
367254
public function write_short($n)
    {
        if ($n < 0 || $n > 65535) {
            throw new AMQPInvalidArgumentException('Short out of range: ' . $n);
        }

        $this->out .= pack('n', $n);

        return $this;
    }
1292809
protected function sendImageMsgToJsonString(WxSendImageMsg $msg)
    {
        $formatStr = '{
                        "touser":"%s",
                        "msgtype":"%s",
                        "image":
                        {
                          "media_id":"%s"
                        }
                    }';
        $result = sprintf($formatStr,   $msg->getToUserName(),
                                        $msg->getMsgType(),
                                        $msg->getMediaId()
                        );


        return $result;
    }