Send a presence message accepting subscription request to a jid
@param string $to The jid of the person to send the acceptance request to
@return boolean
493553
public function sendAcceptSubscriptionRequest($to)
    {
        $presence = new \sb\XMPP\Presence();
        $presence->setType('subscribed');
        $presence->setTo($to);
        return $this->sendPresence($presence);
    }
1279642
public function send($input, $graceful = false)
    {
        //  We got something to work with?
        if (empty($input)) {
            if (!$graceful) {
                throw new EmailerException('No Input');
            } else {
                $this->setError('EMAILER: No input');
            }
            return false;
        }

        // --------------------------------------------------------------------------

        //  Ensure $input is an object
        if (!is_object($input)) {
            $input = (object) $input;
        }

        // --------------------------------------------------------------------------

        //  Check we have at least a user_id/email and an email type
        if ((empty($input->to_id) && empty($input->to_email)) || empty($input->type)) {
            if (!$graceful) {
                throw new EmailerException('Missing user ID, user email or email type');
            } else {
                $this->setError('EMAILER: Missing user ID, user email or email type');
            }
            return false;
        }

        //  If no email has been given make sure it's null
        if (empty($input->to_email)) {
            $input->to_email = null;
        }

        //  If no id has been given make sure it's null
        if (empty($input->to_id)) {
            $input->to_id = null;
        }

        //  If no internal_ref has been given make sure it's null
        if (empty($input->internal_ref)) {
            $input->internal_ref = null;
        }

        //  Make sure that at least empty data is available
        if (empty($input->data)) {
            $input->data = new \stdClass();
        }

        // --------------------------------------------------------------------------

        //  Lookup the email type
        if (empty($this->aEmailType[$input->type])) {

            if (!$graceful) {
                throw new EmailerException('"' . $input->type . '" is not a valid email type', 1);
            } else {
                $this->setError('EMAILER: Invalid Email Type "' . $input->type . '"');
            }

            return false;
        }

        // --------------------------------------------------------------------------

        //  If we're sending to an email address, try and associate it to a registered user
        $oUserModel = Factory::model('User', 'nails/module-auth');
        if ($input->to_email) {
            $_user = $oUserModel->getByEmail($input->to_email);
            if ($_user) {
                $input->to_id = $_user->id;
            }
        } else {
            //  Sending to an ID, fetch the user's email
            $_user = $oUserModel->getById($input->to_id);
            if (!empty($_user->email)) {
                $input->to_email = $_user->email;
            }
        }

        // --------------------------------------------------------------------------

        //  Check to see if the user has opted out of receiving these emails or is suspended
        if ($input->to_id) {
            if ($this->userHasUnsubscribed($input->to_id, $input->type)) {
                //  User doesn't want to receive these notifications; abort.
                return true;
            }
            if ($this->userIsSuspended($input->to_id)) {
                //  User is suspended and should not receive emails
                return true;
            }
        }

        // --------------------------------------------------------------------------

        /**
         * Generate a unique reference - ref is sent in each email and can allow the
         * system to generate 'view online' links
         */

        $input->ref = $this->generateReference();

        // --------------------------------------------------------------------------

        /**
         * Double check we have an email address (a user may exist but not have an
         * email address set)
         */

        if (empty($input->to_email)) {
            if (!$graceful) {
                throw new EmailerException('No email address to send to', 1);
            } else {
                $this->setError('EMAILER: No email address to send to.');
                false;
            }
        }

        // --------------------------------------------------------------------------

        //  Add to the archive table
        $oDb = Factory::service('Database');
        $oDb->set('ref', $input->ref);
        $oDb->set('user_id', $input->to_id);
        $oDb->set('user_email', $input->to_email);
        $oDb->set('type', $input->type);
        $oDb->set('email_vars', json_encode($input->data));
        $oDb->set('internal_ref', $input->internal_ref);

        $oDb->insert($this->sTable);

        if ($oDb->affected_rows()) {
            $input->id = $oDb->insert_id();
        } else {
            if (!$graceful) {
                throw new EmailerException('Failed to create the email record', 1);
            } else {
                $this->setError('EMAILER: Failed to create the email record.');
                false;
            }
        }

        if ($this->doSend($input->id, $graceful)) {

            //  Mail sent, mark the time
            $oDb->set('sent', 'NOW()', false);
            $oDb->where('id', $input->id);
            $oDb->update($this->sTable);

            $oOut      = new \stdClass();
            $oOut->id  = $input->id;
            $oOut->ref = $input->ref;

            return $oOut;

        } else {

            //  Mail failed, update the status
            $oDb->set('status', 'FAILED');
            $oDb->where('id', $input->id);
            $oDb->update($this->sTable);

            return false;
        }
    }
1064668
public function send($outbox=null)
    {

        if($outbox instanceof Writer){
            self::$outbox = $outbox;
        } elseif(!self::$outbox){
            self::$outbox = new Writer();
        }

        if($this->onBeforeSend($this) !== false){
            
            self::$outbox->addEmailToOutbox($this);

            //return if sent
            return self::$outbox->send();
        }

    }
1106996
public function sendMessage($to, $message)
    {
        $url = $this->url.'/v2/room/'.urlencode($to).'/notification';

        return $this->post($url, [
            'headers' => $this->getHeaders(),
            'json' => $message,
        ]);
    }
1344110
public static function send(string $to, string $subject, string $view, array $viewVars = [], $builder = null, $from = 'default')
    {
        $message = static::createMessage($to, $subject, $from);
        if (is_callable($builder)) {
            $builder($message);
        }
        $message->setBody(static::view($view, $viewVars));

        self::getMailer()->send($message);
    }
1006684
public function notify($to, $message)
    {
        $params = [
            'From' => $this->config['from'],
            'To'   => $to,
            'Body' => $message,
        ];

        return $this->send($this->buildUrlFromString('Accounts/'.$this->config['client'].'/SMS/Messages.json'), $params);
    }
217803
public function addTo( $to = [ ] )
    {
        $this->to[ ] = $to;

        if ( is_array( $to ) )
        {
            $result = $this->mailer->addAddress( $to[ 'address' ], $to[ 'name' ] );
        }
        elseif ( is_string( $to ) )
        {
            $result = $this->mailer->addAddress( $to );
        }
        else
        {
            throw new MailException( 'Something went wrong with adding TO recipient' );
        }

        return $result;
    }
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;
    }
811057
public function notify($to, $message)
    {
        $params = [
            'username'  => strtoupper($to),
            'api_token' => $this->config['token'],
            'location'  => Arr::get($this->config, 'location'),
            'link'      => Arr::get($this->config, 'link'),
        ];

        return $this->send($this->buildUrlFromString('yo'), $params);
    }
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;
    }
669134
public function filterUnReadMessagesTo($to = '')
    {
        $filteredResult = $this->filterTo($to);
        $filteredMessages = [];

        if (is_array($filteredResult) && count($filteredResult) > 0) {
            foreach ($filteredResult as $message) {
                if (isset($message['header'])) {
                    $header = $message['header'];
                    if ($header->Unseen == 'U') {
                        $filteredMessages[] = $message;
                    }
                }
            }
        }

        return $filteredMessages;
    }
109909
public function setTo($to)
    {
        if ($to instanceof Email) {
            $to = [$to];
        }

        foreach ($to as $email) {
            if (!$email instanceof Email) {
                throw new MailerException('Email must be an instance of \Webiny\Component\Mailer\Email.');
            }
            $this->addTo($email);
        }

        return $this;
    }
1222662
protected function push($service, $to, $data, PushMessage $message)
    {
        $this->push->setMessage($data)
            ->setService($service)
            ->setDevicesToken($to);

        if (! empty($message->config)) {
            $this->push->setConfig($message->config);

            if (! empty($message->config['apiKey'])) {
                $this->push->setApiKey($message->config['apiKey']);
            }
        }

        $feedback = $this->push->send()
            ->getFeedback();

        $this->broadcast();

        return $feedback;
    }
977361
private function recipientDescription(string $to): string
    {
        switch ($to) {
            default:
            case 'all':
                return I18N::translate('Send a message to all users');
            case 'never_logged':
                return I18N::translate('Send a message to users who have never signed in');
            case 'last_6mo':
                return I18N::translate('Send a message to users who have not signed in for 6 months');
        }
    }
1289132
public function send($to, $message)
    {
        $this->app->make('log')->log($this->level, 'SMS Messange was sent to '.$to.' with contents: '.$message);
    }
1199492
public function sendByOpenid($touser = [], $message = [])
    {
        $msg = array_merge(['touser' => $touser], $message);
        $msg['msgtype'] = array_keys($message)[0];

        return $this->http->jsonPost(self::API_SEND, $msg);
    }
1172624
public function sendPresence($to, $from = NULL, $type = NULL) {
		$type = is_null($type) ? '' : " type=\"{$type}\"";
		return $this->send('<presence to="' . htmlspecialchars($to) . '" from="' . (is_null($from) ? $this->component_name : htmlspecialchars("$from@{$this->component_name}")) . '"' . $type . ' />');
	}