Send message

@param string $to
@param string $text
@param string $from
@param integer $time
@param boolean $test
@param type $partner_id
@return array
320999
public function send($to, $text, $from = null, $time = null, $test = false, $partner_id = null) 
    {
        $url = self::HOST . self::SEND;
        $this->id = null;

        $params = $this->get_default_params();
        $params['to'] = $to;
        $params['text'] = $text;
        
        if ($from)
            $params['from'] = $from;

        if ($time && $time < (time() + 7 * 60 * 60 * 24))
            $params['time'] = $time;

        if ($test)
            $params['test'] = 1;

        if ($partner_id)
            $params['partner_id'] = $partner_id;

        $result = $this->request($url, $params);
        $result = explode("\n", $result);

        return array(
            'code' => $result[0],
            'id' => $result[1],
            'balance' => str_replace('balance=', '', $result[2])
        );
    }
519023
public function send(string $to, Sms $sms, array $params = []): bool
    {
        $content = $sms->content($this->agent_name);
        if (!$content) {
            $this->result->setStatus(false)->setMessage('The agent : ' . $this->agent_name . ' not supported by SMS');
            return false;
        }

        $send_params = [
            'RegionId' => self::ENDPOINT_REGION,
            'AccessKeyId' => $this->config['access_key_id'],
            'Format' => 'JSON',
            'SignatureMethod' => 'HMAC-SHA1',
            'SignatureVersion' => '1.0',
            'SignatureNonce' => uniqid(),
            'Timestamp' => gmdate('Y-m-d\TH:i:s\Z'),
            'Action' => 'SendSms',
            'Version' => '2017-05-25',
            'PhoneNumbers' => $to,
            'SignName' => SmsConfig::getSign(),
            'TemplateCode' => $content,
            'TemplateParam' => json_encode($params, JSON_FORCE_OBJECT),
            'OutId' => '',
        ];
        $send_params['Signature'] = $this->signature($send_params);

        $curl = new CurlRequest();
        list($code,$res) = $curl->request('POST',self::ENDPOINT_URL,['body' =>$send_params ]);

        $this->result->setReceiptData($res)->setContent($content)->setParams($params);

        $receipt_data = json_decode($res,true);
        if ($receipt_data === false) {
            $this->result->setStatus(false)->setMessage('Request failed!');
            return false;
        }
        $this->result->setMessage($receipt_data['Message'])->setReceiptId($receipt_data['RequestId']);
        if ($code == 200) {
            if($receipt_data['Code'] != 'OK') {
                $this->result->setStatus(false);
                return false;
            } else{
                $this->result->setStatus(true)->setReceiptId($receipt_data['BizId']);
                return true;
            }
        } else {
            $this->result->setStatus(false);
            return false;
        }

    }
902595
public function translateArray(array $texts, $to, $from = null)
    {
        $apiCall = new ApiCall\TranslateArray($texts, $to, $from);

        return $this->call($apiCall);
    }
288853
public function send() {
		$msg = array();

		$msg_to = array();
		foreach( $this->mTo as $name => $target ){
			if( !is_string( $name ) ) {
				$msg_to[] = $target;
			} else {
				$msg_to[] = "$name <$target>";
			}
		}
		$msg['to'] = implode( ', ', $msg_to );

		$msg_from = array();
		foreach( $this->mFrom as $name => $target ){
			if( !is_string( $name ) ) {
				$msg_from[] = $target;
			} else {
				$msg_from[] = "$name <$target>";
			}
		}
		$msg['from'] = null;
		if( count( $msg_from ) > 0 ) $msg['from'] = "From: " . implode( ', ', $msg_from );

		$msg_cc = array();
		foreach( $this->mCC as $name => $target ){
			if( !is_string( $name ) ) {
				$msg_cc[] = $target;
			} else {
				$msg_cc[] = "$name <$target>";
			}
		}
		$msg['cc'] = null;
		if( count( $msg_cc ) > 0 ) $msg['cc'] = "CC: " . implode( ', ', $msg_cc );

		$msg_bcc = array();
		foreach( $this->mBCC as $name => $target ){
			if( !is_string( $name ) ) {
				$msg_bcc[] = $target;
			} else {
				$msg_bcc[] = "$name";
			}
		}
		$msg['bcc'] = null;
		if( count( $msg_bcc ) > 0 ) $msg['bcc'] = "BCC: " . implode( ', ', $msg_bcc );

		$msg_rt = array();
		foreach( $this->mRT as $name => $target ){
			if( !is_string( $name ) ) {
				$msg_rt[] = $target;
			} else {
				$msg_rt[] = "$name <$target>";
			}
		}
		$msg['rt'] = null;
		if( count( $msg_rt ) > 0 ) $msg['rt'] = "Reply-to: " . implode( ', ', $msg_rt );

		$msg['subject'] = $this->mSubject;
		$msg['message'] = $this->mMessage;
		$msg['version'] = 'X-Mailer: PHP/' . phpversion();

		$msg['headers'] = $msg['from'] . "\r\n";
		if( !is_null( $msg['rt'] ) ) $msg['headers'] .= $msg['rt'] . "\r\n";
		if( !is_null( $msg['cc'] ) ) $msg['headers'] .= $msg['cc'] . "\r\n";
		if( !is_null( $msg['bcc'] ) ) $msg['headers'] .= $msg['bcc'] . "\r\n";
		$msg['headers'] .= $msg['version'];

		$result = mail( $msg['to'], $msg['subject'], $msg['message'], $msg['headers'] );

		return $result;
	}
557959
public static function sendMessage(string $text, int $to_user_id = USER_ID, int $from_user_id = 0, int $notify_toastr = self::TOASTR_MESSAGE_COLOR_GREEN)
    {
        $message = new UsersMessageEntity();

        return $message
            ->setFromUserId($from_user_id)
            ->setToUserId($to_user_id)
            ->setMessage($text)
            ->setNotify($notify_toastr)
            ->save();
    }
461666
public function send(string $to, Sms $sms, array $params = []): bool
    {
        $content = $sms->content($this->agent_name);
        if (!$content) {
            throw new SmsException('The agent : ' . $this->agent_name . ' not supported by SMS');
        }
        $full_content = $this->getFullContent($content, $params);
        $this->result->setStatus(true)->setContent($full_content)->setParams($params);
        return true;
    }
443107
public function sendMessage($text, $chat_id = null, $disable_web_page_preview = false, $reply_to_message_id = null, $reply_markup = null, $parse_mode = null) {
        $this->sendChatAction(self::ACTION_TYPING, $chat_id);
        return $this->exec('sendMessage', [
            'chat_id' => $this->getChatId($chat_id),
            'text' => $text,
            'parse_mode' => $parse_mode,
            'disable_web_page_preview' => $disable_web_page_preview,
            'reply_to_message_id' => $reply_to_message_id,
            'reply_markup' => json_encode($reply_markup)
        ]);
    }
658885
public function copy( $from, $to )
	{
		try {
			$this->fs->copy( $from, $to );
		} catch( \Exception $e ) {
			throw new Exception( $e->getMessage(), 0, $e );
		}
	}
1180424
public static function sendSimple($to, string $subject, string $message) : array {
		return self::send(['to' => $to, 'subject' => $subject, 'message' => $message]);
	}
428120
public function sendPartnerRequestToManager(array $mailVars, $sendFrom, $sendTo)
    {

        $mailTemplate = $this->createMailTemplate('partner-request-manager', $mailVars);

        if (!empty($mailTemplate)) {
            $subject = $mailTemplate->getSubject();
            $bodyParams = ['bodyContent' => $mailTemplate->getBody()];

            $this->sendMessage($sendFrom, $sendTo, $subject, $bodyParams);
        }


    }
288482
private function sendEmail($to = '', $subject = '', $messageText = '')
    {
        $transport = $this->getServiceLocator()->get('mail.transport');
        $message = new Message();
            
        $message->addTo($to)
                ->addFrom($this->getOptions()->getSenderEmailAdress())
                ->setSubject($subject)
                ->setBody($messageText);

        $transport->send($message);
    }
226520
function send_dm_by_id( $uid, $text, $id = NULL )
	{
		$params = array();
		$this->id_format( $uid );
		$params['text'] = $text;
		$params['uid'] = $uid;
		if ($id) {
			$this->id_format( $id );
			$params['id'] = $id;
		}
		return $this->oauth->post( 'direct_messages/new', $params );
	}
1265496
public static Message create(final String to, final String from, final String text) throws Exception {
    	
    	final Map<String, Object> params = new HashMap<String, Object>();
    	params.put("to", to);
    	params.put("from", from);
    	params.put("text", text);
    	
    	return create(params);
    }
793133
public static function sendToCustomerClub($messages,$numbers,$sendDateTime = null,$canContinueInCaseOfError = true)
	{
		$client     = new Client();
		$messages = (array)$messages;
		$numbers = (array)$numbers;
		if($sendDateTime !== null) {
			$body   = ['Messages'=>$messages,'MobileNumbers'=>$numbers,'SendDateTime'=>$sendDateTime,'CanContinueInCaseOfError'=>$canContinueInCaseOfError];
		} else {
			$body   = ['Messages'=>$messages,'MobileNumbers'=>$numbers,'CanContinueInCaseOfError'=>$canContinueInCaseOfError];
		}
		$result     = $client->post('http://restfulsms.com/api/CustomerClub/Send',['json'=>$body,'headers'=>['x-sms-ir-secure-token'=>self::getToken()],'connect_timeout'=>30]);

		self::DBlog($result,$messages,$numbers);

		return json_decode($result->getBody(),true);

	}
487534
public function send($text = null)
    {
        if ($text) {
            $this->withText($text);
        }

        $this->response = $this->client->sendMessage($this);

        return $this;
    }
1056214
public function sendMessage(
        $chatOrUser,
        $text,
        AbstractPayload $reply_markup = null,
        $reply_to_message_id = null,
        $disable_web_page_preview = false,
        $parse_mode = 'html',
        $disable_notifications = true
    ) {
        Assert::notNull($chatOrUser);
        $this->last_message = new Message(new Unstructured(['text' => $text]));
        try {
            $params = [
                'chat_id'                  => is_object($chatOrUser) ? $chatOrUser->id : $chatOrUser,
                'text'                     => $text,
                'disable_web_page_preview' => $disable_web_page_preview,
                'reply_to_message_id'      => $reply_to_message_id,
                'parse_mode'               => $parse_mode,
                'disable_notifications'    => $disable_notifications,
            ];

            if ($reply_markup) {
                $params['reply_markup'] = $reply_markup->export();
            }

            return $this->request('sendMessage', $params);
        } catch (ClientException $e) {
            if (403 === $e->getResponse()->getStatusCode()) {
                return null;
            } else {
                throw $e;
            }
        }
    }
533183
public function moveMessage($index = -1, $to = '')
    {
        if (empty($to)) {
            return false;
        }

        $msgId = 0;

        if (is_array($this->messages) == true) {
            foreach($this ->messages as $msg) {
                if ($msg['index'] == $index) {
                    $msgId = $msg['index'];
                    break;
                }
            }
        }


        if ($msgId >= 0) {
            $to = imap_utf7_encode($to);

            imap_mail_move($this->conn, $msgId, "INBOX.".$to);
            imap_expunge($this->conn);
        }

        return false;
    }