Composes a mail message with the given body content.
@param \webzop\notifications\Notification $notification the body content
@return \yii\mail\MessageInterface $message
@throws InvalidConfigException
977547
protected function composeMessage($notification)
    {
        if(empty($this->message['to'])){
            throw new InvalidConfigException('The "to" option must be set in EmailChannel::message.');
        }
        $message = $this->mailer->compose();
        Yii::configure($message, $this->message);
        $message->setSubject((string)$notification->getTitle());
        $message->setTextBody((string)$notification->getDescription());
        return $message;
    }
1340268
public function send($notifiable, Notification $notification)
    {
        if (! $notifiable->routeNotificationFor('mail')) {
            return;
        }

        $message = $notification->toMail($notifiable);

        $this->mailer->send($message->view, $message->data(), function ($m) use ($notifiable, $notification, $message) {
            $recipients = $notifiable->routeNotificationFor('mail');

            if (is_array($recipients)) {
                $m->bcc($recipients);
            } else {
                $m->to($recipients);
            }

            $m->subject($message->subject ?: Str::title(
                Str::snake(class_basename($notification), ' ')
            ));

            foreach ($message->attachments as $attachment) {
                $m->attach($attachment['file'], $attachment['options']);
            }

            foreach ($message->rawAttachments as $attachment) {
                $m->attachData($attachment['data'], $attachment['name'], $attachment['options']);
            }
        });
    }
926322
protected function pushNotification($notification, $notifiable)
    {
        if ($notifiable instanceof NotifiableGroup) {
            foreach ($notifiable->getGroup() as $toBeNotified) {
                $this->push($notification, $toBeNotified);
            }
        } else {
            // @todo Change this fucking shite
            $notification = $notifiable->notifications()->create($notification);

            event(new NotificationAdded($notification, $notifiable));
        }
    }
829089
public function send($notifiable, Notification $notification)
    {
        $message = collect($notification->toSms($notifiable));
        $sms = new EasySms(config('easysms'));
        if (! ($message->has('content') && $message->has('template') && $message->has('data') && $message->has('phone'))) {
            throw new GeneralException('短信消息实体必须带有 `content`, `template`, `data`, `phone` 字段。');
        }

        try {
            $response = $sms->send($message['phone'], $message->except('phone')->all());
        } catch (NoGatewayAvailableException $e) {
            Log::error('短信发送失败');
        }


    }
351141
protected function queueNotification($notifiables, $notification)
    {
        if (version_compare($this->app->version(), '5.2', '<')) {
            $this->app->make(Bus::class)->dispatch(
                (new SendQueuedNotifications($notifiables, $notification))
                    ->onQueue($notification->queue)
                    ->delay($notification->delay)
            );
        } else {
            $this->app->make(Bus::class)->dispatch(
                (new SendQueuedNotifications($notifiables, $notification))
                    ->onConnection($notification->connection)
                    ->onQueue($notification->queue)
                    ->delay($notification->delay)
            );
        }
    }
1178725
public function send($notifiable, Notification $notification)
    {
        if (! $url = $notifiable->routeNotificationFor('Webhook')) {
            return;
        }

        $webhookData = $notification->toWebhook($notifiable)->toArray();

        $response = $this->client->post($url, [
            'body' => json_encode(Arr::get($webhookData, 'data')),
            'verify' => false,
            'headers' => Arr::get($webhookData, 'headers'),
        ]);

        if ($response->getStatusCode() >= 300 || $response->getStatusCode() < 200) {
            throw CouldNotSendNotification::serviceRespondedWithAnError($response);
        }
    }
1053560
public function addMessage(Message $message): Email
    {
        if (null === $this->message->getBody()) {
            $this->message->setBody($message->getBody(), $message->getContentType());

            return $this;
        }

        $this->message->addPart($message->getBody(), $message->getContentType());

        return $this;
    }
615272
public function setRPCNotification($notification)
    {
        empty($notification) ? $this->notification = false : $this->notification = true;
    }
966935
public function send($notifiables, $notification)
    {
        return (new NotificationSender(
            $this, $this->app->make(Bus::class), $this->app->make(Dispatcher::class), $this->locale)
        )->send($notifiables, $notification);
    }
981546
public function send($notifiable, Notification $notification)
    {
        if (! $url = $notifiable->routeNotificationFor('slack')) {
            return;
        }

        $message = $notification->toSlack($notifiable);

        $this->http->post($url, [
            'json' => [
                'text' => $message->content,
                'attachments' => $this->attachments($message),
            ],
        ]);
    }
1123923
public function send($notifiable, Notification $notification)
    {
        if (! $to = $notifiable->routeNotificationFor('plivo')) {
            return;
        }

        $message = $notification->toPlivo($notifiable);

        if (is_string($message)) {
            $message = new PlivoMessage($message);
        }

        $response = $this->plivo->send_message([
            'src' => $message->from ?: $this->from,
            'dst' => $to,
            'text' => trim($message->content),
        ]);

        if ($response['status'] !== 202) {
            throw CouldNotSendNotification::serviceRespondedWithAnError($response);
        }

        return $response;
    }
1314883
public function sendNotification()
    {
        if (($from = self::config()->get('mail_sender')) && empty($from)) {
            $from = Config::inst()->get('Email', 'admin_email');
        }

        if (($to = self::config()->get('mail_receiver')) && empty($to)) {
            $to = Config::inst()->get('Email', 'admin_email');
        }

        $email = new Email();
        $email->setSubject(_t(
            'NotificationMail.TITLE',
            'Nieuwe reservering voor {event}',
            null, array('event' => $this->Event()->Title)
        ));

        $email->setFrom($from);
        $email->setTo($to);
        $email->setTemplate('NotificationMail');
        $email->populateTemplate($this);
        $this->extend('updateNotificationMail', $email);
        return $email->send();
    }
495179
private function createPostFields(Notification $notification)
    {
        /**
         * Required fields
         */
        $data = [
            'user_credentials'           => $this->accessToken,
            'notification[title]'        => $notification->getTitle(),
            'notification[long_message]' => $notification->getContent()
        ];

        /**
         * Optional fields
         */
        if (!empty($this->getSourceName())) {
            $data['notification[source_name]'] = $this->getSourceName();
        }

        if (!empty($this->getIconUrl())) {
            $data['notification[icon_url]'] = $this->getIconUrl();
        }

        if (!empty($this->getSound())) {
            $data['notification[sound]'] = $this->getSound();
        }

        if (!empty($this->getOpenUrl())) {
            $data['notification[open_url]'] = $this->getOpenUrl();
        }

        return $data;
    }
1313564
public function handle(NotificationInterface $notification, $level)
    {
        if ($notification instanceof AttributeAwareInterface)
        {
            $options = $notification->attributes();
        }
        else
        {
            $options = [];
        }

        if ($notification instanceof TitleAwareInterface)
        {
            $options['header'] = $notification->title();
        }

        $variable = [
            'message' => $notification->message(),
            'type'    => isset($this->levelMapping[$level]) ? $this->levelMapping[$level] : self::STANDARD,
            'options' => $options
        ];

        $current = $this->smarty->getTemplateVars($this->var);

        if (!$current)
        {
            $this->smarty->assign($this->var, [$variable]);
        }
        else
        {
            $this->smarty->append($this->var, $variable);
        }

        return true;
    }
125684
public function send($notifiable, Notification $notification)
    {
        try {
            $to = $this->getTo($notifiable);
            $message = $notification->toTwilio($notifiable);
            $useSender = $this->canReceiveAlphanumericSender($notifiable);

            if (is_string($message)) {
                $message = new TwilioSmsMessage($message);
            }

            if (! $message instanceof TwilioMessage) {
                throw CouldNotSendNotification::invalidMessageObject($message);
            }

            return $this->twilio->sendMessage($message, $to, $useSender);
        } catch (Exception $exception) {
            $event = new NotificationFailed($notifiable, $notification, 'twilio', ['message' => $exception->getMessage(), 'exception' => $exception]);
            if (function_exists('event')) { // Use event helper when possible to add Lumen support
                event($event);
            } else {
                $this->events->fire($event);
            }
        }
    }
590850
public function send($notifiable, Notification $notification)
    {
        $message = $notification->toHipChat($notifiable);

        if (is_string($message)) {
            $message = new HipChatMessage($message);
        }

        if (! in_array(get_class($message), [HipChatMessage::class, HipChatFile::class])) {
            throw CouldNotSendNotification::invalidMessageObject($message);
        }

        $to = $message->room ?: $notifiable->routeNotificationFor('HipChat');
        if (! $to = $to ?: $this->hipChat->room()) {
            throw CouldNotSendNotification::missingTo();
        }

        try {
            $this->sendMessage($to, $message);
        } catch (ClientException $exception) {
            throw CouldNotSendNotification::hipChatRespondedWithAnError($exception);
        } catch (Exception $exception) {
            throw CouldNotSendNotification::internalError($exception);
        }
    }
317704
public function send($notifiable, Notification $notification)
    {
        $message = $notification->toMail($notifiable);

        if (! $notifiable->routeNotificationFor('mail', $notification) &&
            ! $message instanceof Mailable) {
            return;
        }

        if ($message instanceof Mailable) {
            return $message->send($this->mailer);
        }

        $this->mailer->send(
            $this->buildView($message),
            array_merge($message->data(), $this->additionalMessageData($notification)),
            $this->messageBuilder($notifiable, $notification, $message)
        );
    }