Send message

@param string $from message sender, push when not null
@param string $type chat or grpchat or boardcast
@param string $to message receiver
@param string $body message
@param string $style css

@return 'ok'
170142
public function message($from, $to, $body, $type = 'chat', $style='', $timestamp = null) {
        if(!$timestamp) $timestamp = microtime(true) * 1000;
		$data = array_merge($this->reqdata(), array(
			'nick' => $this->endpoint->nick,
			'to' => $to,
			'type' => $type,
			'body' => $body,
			'style' => $style,
			'timestamp' => $timestamp,
		));
        if($from) $data['from'] = $from;
		return $this->request('messages', $data, 'POST');
	}
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();
    }
1013643
public function endpoint_sendmessage($to = NULL, $from = NULL, $body = NULL)
        {
            return $this->sendmessage($to, $from, $body);
        }
703425
protected function publishFile($from, $to)
    {
        if ($this->files->exists($to) || !$this->files->exists($from)) {
            return false;
        }

        $this->files->copy($from, $to);
        $this->info('Stub published: ' . basename($to));

        return true;
    }
168563
public function message($to = '', $subject = '', $body = '')
    {
        $message = $this->transport->newMessage();

        if ($to) {
            $message->to($to);
        }
        if ($subject) {
            $message->subject($subject);
        }
        if ($body) {
            $message->body($body);
        }

        $message->setMailer($this);

        return $message;
    }
567393
public function sendSimpleMessage($to, $body)
    {

        $message = new \sb\XMPP\Message();

        $message->setTo($to);
        $message->setBody($body);
        $this->sendMessage($message);
    }
114016
public static function setMessage($message, $from = null, $color = null)
    {
        if (!empty($from)) {
            static::setFrom($from);
        }
        if (!empty($color)) {
            static::setColor($color);
        }

        if (is_object($message)) {
            static::$message = $message;
        } else {
            static::$message = new Message();
            static::$message->setMessage($message);
            static::$message->setFrom(static::getFrom());
            static::$message->setColor(static::getColor());
        }
    }
157838
public function sendTemplateMessageByType($touser, $type, $data, $url = null) {
		return isset($this->templates[$type]) && $this->sendTemplateMessage($touser, $this->templates[$type], $data, $url);
	}
1149267
public function send( $to, $subject, $body )
	{
		// Debug advice:
		if ( \Sifo\Domains::getInstance()->getDebugMode() )
		{
			$this->_dispatchMailController( $to, $subject, $body );
		}
		return parent::send( $to, $subject, $body );
	}
207843
public static function sendMail($from,$to,$title,$content,$is_html=1){
		$m = self::getMailOb($from,$to,$title,$content,$is_html);
		if($m){
			$m->send();
			return true;
		}
		
		return false;
	}
91159
public function chatSend($sender, $receiver, $content, $type = 'text') {
        $result = $this->httpPost(self::WECHAT_CHAT_SEND_PREFIX, [
            'access_token' => $this->getAccessToken(),
            'receiver' => json_encode($receiver),
            'sender' => $sender,
            'msgtype' => $type,
            $type => json_encode($content),
        ]);
        return ($result['errmsg'] == 'ok') ? true : $result['errmsg'];
    }
42321
public function send( $to, $subject, $body, $text = false ) {
		if ( $this->_is_sending || empty( $to ) || empty( $subject ) || ( empty( $body ) && empty( $text ) ) ) {
			return false;
		}

		$subject = str_replace( [ "\r\n", "\r", "\n" ], '', $subject );
		$this->remove_special_space( $subject );
		$this->remove_special_space( $body );

		if ( ! is_array( $body ) ) {
			$body = [ 'text/html' => $body ];
		}
		if ( ! empty( $text ) ) {
			$this->remove_special_space( $text );
			$body['text/plain'] = $text;
		}

		$cssToInlineStyles = new CssToInlineStyles;
		$messages          = [];
		$content_type      = 'text/html';
		foreach ( $body as $type => $message ) {
			is_array( $message ) and $message = reset( $messages );
			if ( 'text/html' === $type ) {
				$message = $this->get_view( 'common/mail', [ 'subject' => $subject, 'body' => $message ] );
				$message = $cssToInlineStyles->convert( $message );
				$message = preg_replace( '/<\s*style.*?>[\s\S]*<\s*\/style\s*>/', '', $message );
			} elseif ( 'text/plain' !== $type ) {
				continue;
			}
			$messages[ $type ] = $message;
			$content_type      = $type;
		}

		if ( empty( $messages ) ) {
			return false;
		}
		if ( count( $messages ) > 1 ) {
			$content_type = 'multipart/alternative';
		}

		// このチケットがマージされたら以下の処理は不要
		// https://core.trac.wordpress.org/ticket/15448

		add_action( 'phpmailer_init', $set_phpmailer = function ( $phpmailer ) use ( &$set_phpmailer, $messages, $content_type ) {
			/** @var \PHPMailer $phpmailer */
			remove_action( 'phpmailer_init', $set_phpmailer );
			$phpmailer->Body    = '';
			$phpmailer->AltBody = '';
			foreach ( $messages as $type => $message ) {
				if ( 'text/html' === $type ) {
					$phpmailer->Body = $message;
				} elseif ( 'text/plain' === $type ) {
					$phpmailer->AltBody = $message;
				}
			}
			$phpmailer->ContentType = $content_type;
		} );

		// suppress error
		if ( ! isset( $_SERVER['SERVER_NAME'] ) ) {
			$_SERVER['SERVER_NAME'] = '';
		}

		// is sending
		$this->_is_sending = true;

		$result = wp_mail( $to, $subject, reset( $messages ) );

		$this->_is_sending = false;

		return $result;
	}
1012497
public function send($to, $subject, $body, $headers)
    {
        return mail(
            $to,
            $subject,
            $body,
            $headers
        );
    }
1372877
public static function getPlainMail($to, $from, $body, $subject) {
        $mail = new MailMessage($to, $from, $body, $subject);
        return $mail;
    }
1189921
public function onMessage(ConnectionInterface $from, $message)
    {
        $message = json_decode($message);

        // TODO: Various auth checks and safety. We don't want to try to handle anything/everything from the client!
        $channel = $message->message->channel;

        if ($message->event == 'subscribe') {
            // Tie the connection to the channel
            $this->subscribedTopics[$channel][] = $from;
        }
    }
1067117
protected function getDefaultMessage($from, $encoding, $to, $subject, $body) {
        if(is_string($from)) {
            $from = array('email' => $from, 'name' => $from);
        }

        $message = new MailMessage();
        $message->setFrom($from['email'], $from['name'])
            ->setEncoding($encoding)
            ->setSubject($subject)
            ->setBody($body)
            ->setTo($to);

        return $message;
    }
597318
public function send($to, $text, $sender = null, $messageId = 0)
    {
        $params = [
            'id' => $messageId,
            'to' => $to,
            'text' => $text,
        ];

        if (!empty($sender)) {
            $params['from'] = $sender;
        }

        return $this->call('send', $params);
    }