Sends Message to a Receiver.
@access		public
@param		string		$message		Message to send to Receiver
@param		string		$receiver		JID of Receiver
@return		void
@throws		RuntimeException			if XMPP connection is not established
19897
public function sendMessageTo( $message, $receiver )
	{
		if( is_string( $receiver ) )
			$receiver	= new Net_XMPP_JID( $receiver );
		if( !$this->xmpp )
			throw new RuntimeException( 'Not connected to Server.' );
		$this->xmpp->message( $receiver->get(), $message );
	}
154695
public function push(Message $message)
    {
        if (empty($this->params)) {
            throw new \RuntimeException('Please set up this client using setUp() method before pushing messages.');
        }

        $tokens = $message->getTokens();
        if (empty($tokens)) {
            throw new \RuntimeException('No device token set. Please add at least 1 token using Message::addToken() before trying to push the message.');
        }

        $payload = $message->getPayloadAsJson();

        $headers = array(
            'Authorization: key='.$this->params['api_access_key'],
            'Content-Type: application/json',
        );

        $this->logger->info('Sending GcmMessage to Google Cloud Messaging server', array(
            'payload' => $payload,
        ));

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $this->params['endpoint']);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
        curl_exec($ch);
        curl_close($ch);
    }
1212627
public function write_message($message)
  {
    $binary_length = strlen($message);
    
    $max_binary_frame_length = BUFFER_SIZE - 4;
    $sended_length = 0;
    
    $frames = array();
    while ($sended_length < $binary_length) {
      $not_sended_length = $binary_length - $sended_length;
      $binary_frame_length = ($not_sended_length > $max_binary_frame_length) ? $max_binary_frame_length : $not_sended_length;
      $frames[] = substr($message, $sended_length, $binary_frame_length);
      $sended_length += $binary_frame_length;
    }
    
    foreach ($frames as $frame) {
      $msg = pack("N", strlen($frame)).$frame;
      socket_write ( $this->socket, $msg, strlen($msg));
    }
    $footer = pack("N", 0);
    //socket_send ($this->socket, $header, strlen($header) , 0);
    $x = socket_write ($this->socket, $footer, strlen($footer));
    
  }
613568
public function sendMessage($message)
    {
        if ($payload = $this->getJsonPayload($message)) {
            $response = $this->getHttpClient()
                ->post($this->getWebhook(), [
                    'headers' => ['Content-Type' => 'application/json'],
                    'body' => $payload,
                ]);

            return 200 === $response->getStatusCode();
        }

        return false;
    }
740589
public function send(MessageInterface $message, $skipErrors = true) {
        $this->clearErrors();

        $command = $this->prepareCommand($message->getText());

        foreach ($message->getRecipient() as $recipient) {
            // execute command
            $command = str_replace('#RECIPIENT#', $recipient, $command);

            $return = 0;
            $output = [];
            exec($command, $output, $return);

            if ($return !== 0) {
                $errorMsg = sprintf("Error while sending message to \"%s\".", $recipient);
                $this->addError(new SendingError($recipient, self::ERROR_NOT_SAVED, $errorMsg));
                if (!$skipErrors) {
                    throw new RuntimeException($errorMsg, self::ERROR_NOT_SAVED);
                }
            }
        }
        return $this->getErrors()->count() === 0;
    }
759052
public function send(OutgoingMessage $message)
    {
        $composedMessage = $message->composeMessage();

        $data = [
            'PhoneNumbers' => $message->getTo(),
            'Message'      => $composedMessage,
        ];

        $this->buildCall('/sending/messages');
        $this->buildBody($data);

        $this->postRequest();
    }
974235
protected function send($message)
	{
		$message = $this->encodeMessage($message);
		$this->ws->send($message);
	}
267823
public function send(OutgoingMessage $message)
    {
        $messageToSend = $message->serialize();
        $length = strlen($messageToSend);
        $this->logger->debug(
            '------ Sending: ------ ' . "\n" . $messageToSend . '----------'
        );
        $this->lastActionId = $message->getActionId();
        if (@fwrite($this->socket, $messageToSend) < $length) {
            throw new ClientException('Could not send message');
        }
        $read = 0;
        while ($read <= $this->rTimeout) {
            $this->process();
            $response = $this->getRelated($message);
            if ($response != false) {
                $this->lastActionId = false;
                return $response;
            }
            usleep(1000); // 1ms delay
            if ($this->rTimeout > 0) {
                $read++;
            }
        }
        throw new ClientException('Read timeout');
    }
58678
public function onMessage(string $message, string $address, SocketInterface $socket)
    {
        try {
            $this->dispatch(Events::MESSAGE, new MessageEvent($socket, $address, $message));
            $socket->send($this->handleQueryFromStream($message), $address);
        } catch (\Exception $exception) {
            $this->dispatch(Events::SERVER_EXCEPTION, new ServerExceptionEvent($exception));
        }
    }
355508
function Send($message)
    {
        $mailer = new PHPMailer();

		// this prevents problems with phpmailer not being able to locate the language path
		$mailer->SetLanguage("en", $this->LangPath );

        $mailer->From = $message->From->Email;
        $mailer->FromName = $message->From->RealName;
        if ($message->ReplyTo) $mailer->AddReplyTo($message->ReplyTo->Email,$message->ReplyTo->RealName);
        $mailer->Subject = $message->GetSubject();
        $mailer->Body = $this->FixBareLB($message->GetBody());
        $mailer->ContentType = ($message->Format == MESSAGE_FORMAT_TEXT) ? "text/plain" : "text/html";
        $mailer->Mailer = strtolower($this->Method);
        $mailer->Host = $this->Path;
        $mailer->Sendmail = $this->Path;

        // use authentication if necessary
        if ($this->AuthUsername)
        {
        	  $mailer->SMTPAuth = true;
        	  $mailer->Username = $this->AuthUsername;
        	  $mailer->Password = $this->AuthPassword;
        }
        
        // if custom headers are to be provided, include them in the message
        foreach ($message->Headers as $header_key => $header_val) 
        {
        	$mailer->AddCustomHeader($header_key.': '.$header_val);
        }

		if ($message->Sender)
		{
			$this->_log[] = "Adding Sender ".$message->Sender;

			// phpmailer accepts this but it seems to not work consistently..?
			// $mailer->Sender = $message->Sender;

			// instead add the dang headers ourselves
			$mailer->AddCustomHeader("Sender: " . $message->Sender);
			$mailer->AddCustomHeader("Return-Path: " . $message->Sender);
		}

		if (!$this->IsValid($mailer->From))
		{
			$this->_errors[] = "Sender '".$mailer->From."' is not a valid email address.";
			return MAILER_RESULT_FAIL;
		}

		// add the recipients
        foreach ($message->Recipients as $recipient)
        {
			$this->_log[] = "Adding Recipient ".$recipient->RealName." [".$recipient->Email."]";

			if (!$this->IsValid($recipient->Email))
			{
				$this->_errors[] = "Recipient '".$recipient->Email."' is not a valid email address.";
				return MAILER_RESULT_FAIL;
			}

			$mailer->AddAddress($recipient->Email,$recipient->RealName);

		}

		foreach ($message->CCRecipients as $recipient)
        {
			$this->_log[] = "Adding CC Recipient ".$recipient->RealName." [".$recipient->Email."]";

			if (!$this->IsValid($recipient->Email))
			{
				$this->_errors[] = "CC Recipient '".$recipient->Email."' is not a valid email address.";
				return MAILER_RESULT_FAIL;
			}

			$mailer->AddCC($recipient->Email,$recipient->RealName);
		}

		foreach ($message->BCCRecipients as $recipient)
        {
			$this->_log[] = "Adding BCC Recipient ".$recipient->RealName." [".$recipient->Email."]";

			if (!$this->IsValid($recipient->Email))
			{
				$this->_errors[] = "BCC Recipient '".$recipient->Email."' is not a valid email address.";
				return MAILER_RESULT_FAIL;
			}

			$mailer->AddBCC($recipient->Email,$recipient->RealName);
		}

        $result = MAILER_RESULT_OK;

        $this->_log[] = "Sending message using " . $mailer->Mailer;

        ob_start(); // buffer output because class.phpmailer.php Send() is chatty and writes to stdout

        $fail = !$mailer->Send();

		ob_end_clean(); // clear the buffer

        if ( $fail || $mailer->ErrorInfo)
        {
            $result = MAILER_RESULT_FAIL;
            $this->_errors[] = trim( str_replace(array('<p>','</p>'),array(', ',''),$mailer->ErrorInfo) );
        }

        return $result;
    }
768210
public function sendHeader($message, $code = null)
    {
        if (!($this->request instanceof WebRequest)) {
            return;
        }
        
        if ($code !== null) {
            header($message, true, $code);
        } else {
            header($message);
        }
    }
1169240
public function send()
    {
        if (headers_sent($file, $line)) {
            throw new RuntimeException("Headers already sent in {$file} on line {$line}."); // @codeCoverageIgnore
        }

        foreach ($this->headers() as $key => $value) {
            header("{$key}: {$value}", true);
        }
    }
92726
protected function sendSwiftMessage( $message )
	{
		Hooks::trigger( 'mailer.sending', compact( $message ) );

		try
		{
			$this->swift->send( $message, $this->failedRecipients );
		}
		finally
		{
			$this->swift->getTransport()->stop();
		}
	}
148324
public function send(Message $message)
    {
        $response = $this->guzzleClient->post('/messages', [
            'json' => [
                'originator' => $message->getOriginator(),
                'recipients' => $message->getRecipient(),
                'body'       => $message->getBody(),
            ],
            'http_errors' => false,
        ]);

        try {
            $document = JsonHelper::decode((string) $response->getBody());
        } catch (\RuntimeException $e) {
            throw new ApiRuntimeException('The MessageBird server did not return valid JSON.', [], $e);
        }

        if (isset($document['errors'])) {
            $errors = $document['errors'];
        } else {
            $errors = [];
        }

        $statusCode = (int) $response->getStatusCode();

        if (!in_array($statusCode, [200, 201, 204, 401, 404, 405, 422]) && !($statusCode >= 500 && $statusCode < 600)) {
            throw new ApiRuntimeException(sprintf('Unexpected MessageBird server behaviour (HTTP %d)', $statusCode), $errors);
        }

        if (!isset($document['recipients']['items'][0]['status'])) {
            $deliveryStatus = SendMessageResult::STATUS_NOT_SENT;
        } else {
            $deliveryStatus = $document['recipients']['items'][0]['status'];
        }

        return new SendMessageResult($deliveryStatus, $errors);
    }
22511
public function send(Message $message) : void
    {
        $destination = $this->getRedirectURL($message);
        Utils::getContainer()->redirect($destination);
    }
1353802
public static function send($message = '', $status = 200)
    {
        if (self::$response === null) {
            self::init();
        }

        self::$response->setStatusCode(intval($status));
        self::$response->setContent(strval($message));
        self::$response->send();
    }
981587
public function send(Message $mail): void
    {
        if (!$this->mailers) {
            throw new InvalidArgumentException('At least one mailer must be provided.');
        }

        $failures = [];
        for ($i = 0; $i < $this->retryCount; $i++) {
            if ($i > 0) {
                \usleep($this->retryWaitTime * 1000);
            }

            foreach ($this->mailers as $mailer) {
                try {
                    $mailer->send($mail);

                    return;

                } catch (SendException $e) {
                    $failures[] = $e;
                    null === $this->onFailure || ($this->onFailure)($this, $e, $mailer, $mail);
                }
            }
        }

        $e = new FallbackMailerException('All mailers failed to send the message.');
        $e->failures = $failures;
        throw $e;
    }