Send Raw Message

@param $message
@return bool
161166
private function sendRawMessage($message)
    {
        try {
            $this->mailer->raw($message, function ($message) {


                if (config('pigeon.dev.override')) {
                    $message->to(config('pigeon.dev.override_email'));
                } else {
                    $message->to($this->to);
                }

                // Set message parts
                $message->subject($this->subject)
                    ->cc($this->cc)
                    ->bcc($this->bcc)
                    ->replyTo($this->reply_to)
                    ->sender($this->sender);

                if (!empty($this->from)) {
                    $message->from($this->from);
                }

                // Set all attachments
                foreach ($this->attachments as $a) {
                    $message->attach($a['path'], $a['options']);
                }
            });
        } catch (ErrorException $e) {
            $msg = 'Pigeon could not send message: ' . $e->getMessage();
            $this->logger->error($msg);
            return false;
        } catch (\Swift_TransportException $e) {
            $msg = 'SMTP failure: ' . $e->getMessage();
            $this->logger->error($msg);
            return false;
        }

        return true;
    }
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;
    }
874728
protected function sending(Message $message)
    {
        $phpMailer = new PHPMailer();
        $phpMailer->isSMTP();
        $phpMailer->SMTPDebug = $this->config[ 'debug' ];

        $host = $this->config[ 'host' ];

        if (is_array($this->config[ 'host' ])) {
            $host = implode(';', $this->config[ 'host' ]);
        }

        $phpMailer->Host = $host;
        $phpMailer->SMTPAuth = $this->config[ 'auth' ];
        $phpMailer->Username = $this->config[ 'username' ];
        $phpMailer->Password = $this->config[ 'password' ];
        $phpMailer->SMTPSecure = $this->config[ 'encryption' ];
        $phpMailer->Port = $this->config[ 'port' ];

        // Set from
        if (false !== ($from = $message->getFrom())) {
            $phpMailer->setFrom($from->getEmail(), $from->getName());
        }

        // Set recipient
        if (false !== ($to = $message->getTo())) {
            foreach ($to as $address) {
                if ($address instanceof Address) {
                    $phpMailer->addAddress($address->getEmail(), $address->getName());
                }
            }
        }

        // Set reply-to
        if (false !== ($replyTo = $message->getReplyTo())) {
            $phpMailer->addReplyTo($replyTo->getEmail(), $replyTo->getName());
        }

        // Set content-type
        if ($message->getContentType() === 'html') {
            $phpMailer->isHTML(true);
        }

        // Set subject, body & alt-body
        $phpMailer->Subject = $message->getSubject();
        $phpMailer->Body = $message->getBody();
        $phpMailer->AltBody = $message->getAltBody();

        if (false !== ($attachments = $message->getAttachments())) {
            foreach ($attachments as $filename => $attachment) {
                $phpMailer->addAttachment($attachment, $filename);
            }
        }

        if ( ! $phpMailer->send()) {
            $this->addError(100, $phpMailer->ErrorInfo);

            return false;
        }

        return true;
    }
812380
public function sendMessage(string $message) : ?Message 
    {
        $data = (object)[
            'messageEventDetail' => (object)[
                'eventCategoryCode' => MessageType::Text, 
                'messageDetail' => (object)[
                    'body' => $message
                ]
            ]
        ];

        $parameters = [
            [
                'name' => 'messageEventDetail',
                'contents' => json_encode($data, JSON_PRETTY_PRINT),
                'headers' => [
                    'Content-Type' => 'application/json; charset=utf-8'
                ]
            ]
        ];

        $response = $this->postMultiPart(sprintf(MessageThread::MESSAGE_THREAD_ENDPOINT . 'threads/%s/messages', $this->messageThreadId), $parameters);

        $messageFields = $this->info(1, true);

        if (!isset($messageFields->threadEvents)) return null;

        $messageData = $messageFields->threadEvents[0];

        return new Message($this->client, $messageData->messageEventDetail, $this);
    }
194334
protected function sendMessage(Message $message) {
		if(!$this->isIgnored($message)) {
			parent::sendMessage($message);
			$this->sentMessages[] = $message;
		}
	}
1243968
public function wrapAndSerialize($message)
    {
        $envelope = $this->envelopeFactory->wrapMessageInEnvelope($message);

        $serializedMessage = $this->objectSerializer->serialize($message);

        return $this->objectSerializer->serialize($envelope->withSerializedMessage($serializedMessage));
    }
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;
    }
801117
protected function sendRaw(OutgoingMessage $message)
    {
        $message = $this->mailer->raw($message->getView(), function ($email) use ($message) {
            $this->generateMessage($email, $message);
        });

        return $message;
    }
58626
public function send($message, array $options = [])
    {
        $config = Ioc::getConfig();

        if (empty($options['force']) && !$config->get('mail.enabled', true)) {
            return true;
        }

        if (\is_callable($message)) {
            $msgObject = $this->createMessage();

            $message = $message($msgObject, $this);

            if (!$message instanceof MailMessage) {
                $message = $msgObject;
            }
        }

        if (!$message instanceof MailMessage) {
            throw new \InvalidArgumentException(sprintf('Mail Message should instance of %s', MailMessage::class));
        }

        $this->triggerEvent('onMailerBeforeSend', [
            'message' => $message,
            'manager' => $this,
        ]);

        // Set default sender
        if (!$message->getFrom()) {
            if ($config->exists('mail.from.email')) {
                $message->from($config->get('mail.from.email'), $config->get('mail.from.name'));
            }
        }

        // CC/BCC
        if ($cc = $config->get('mail.cc')) {
            if (is_string($cc)) {
                $cc = array_filter(array_map('trim', explode(',', $cc)), 'strlen');
            }

            $message->cc($cc);
        }

        if ($bcc = $config->get('mail.bcc')) {
            if (is_string($bcc)) {
                $bcc = array_filter(array_map('trim', explode(',', $bcc)), 'strlen');
            }

            $message->bcc($bcc);
        }

        $result = $this->getAdapter()->send($message);

        $this->triggerEvent('onMailerAfterSend', [
            'message' => $message,
            'manager' => $this,
            'result' => &$result,
        ]);

        return $result;
    }
1040686
public function sendRequest(array $message): bool
    {
        try {
            $args = array(
                "SenderID" => $message['from'],
                "SMSType" => "Transactional",
                "Message" => $message['content'],
                "PhoneNumber" => $message['to']
            );

            $this->sns->publish($args);
        } catch (\Aws\Sns\Exception\SnsException $e) {
            throw new \Matthewbdaly\SMS\Exceptions\ClientException();
        }

        return true;
    }
1136886
public function send($raw_message = null)
    {
        // Set Optional Message Data
        if (!is_null($raw_message)) {
            $send_result = $this->sendRawMessage($raw_message);
        } else {
            $send_result = $this->sendMessage();
        }

        // Reset to default after send
        $this->restoreDefaultMessageType();

        return (bool) $send_result;
    }
241663
protected function isValidMessage($message): Message
    {
        if ($message instanceof Message) {
            return $message;
        }

        if (\is_string($message) || $message instanceof Attachment) {
            return Message::create($message);
        }

        throw new MessengerException(sprintf(
            'message must be a string or an instance of %s or %s.',
            Message::class,
            Attachment::class
        ));
    }
760282
public function request($message)
    {

        try {
            $body = $this->serializer->serialize($message);

            $data = $this->executeRequest($body);

            return $this->serializer->deserialize($data);
        } catch (HomerException $e) {
            $this->disconnect();

            throw $e;
        } catch (Throwable $e) {
            $this->disconnect();

            Log::channel('homer')->warning('Send rpc request failed', [
                'exception' => $e
            ]);

            throw new TransportException('Send rpc request failed, cause: '.$e->getMessage(), 0, $e);
        }
    }
55768
public function send($message)
    {
        try {
            $code = 200;
            $this->sendCommand($this->getTargetServiceName(), $message, false);
            $message = 'Command has been sent';
        } catch (\Exception $exception) {
            $message = $exception->getMessage();
            $code = $exception->getCode();
        }

        return new Response(
            json_encode(['message' => $message]),
            (!empty($code)) ? $code : 500
        );
    }
185452
private function SendMessage($message)
    {
        $this->signal_data->message = $message;
        
        $this->Send(
            \Peg\Lib\Signals\Type\Definitions::IMPORT_MESSAGE,
            $this->signal_data
        );
    }
619310
public function send(Message $message)
    {
        return $this->guzzleClient->post(
            $this->getApiUrl(),
            [
                'headers' => [
                    'Authorization' => sprintf('key=%s', $this->apiKey),
                    'Content-Type' => 'application/json'
                ],
                'body' => json_encode($message)
            ]
        );
    }
1059850
public function send($message, array $options = [])
    {
        $sms = new Message($options);
        $this->request('sms', $sms->getParams());
        $response = $this->getResponse();

        if ($response['error_code'] !== '000') {
            $this->errors[] = $response['error_code'];
            return false;
        }

        return true;
    }