Send the given Message.

@param \Swift_Mime_Message $message
@param string[]           $failedRecipients An array of failures by-reference
@throws \Swift_TransportException
@return int
427526
public function send(\Swift_Mime_Message $message, &$failedRecipients = null)
    {
        $failedRecipients = (array) $failedRecipients;

        if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) {
            $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
            if ($evt->bubbleCancelled()) {
                return 0;
            }
        }

        $count = (
            \count((array) $message->getTo())
            + \count((array) $message->getCc())
            + \count((array) $message->getBcc())
        );

        $filename = 'Mail_' . \time() . '_' . \mt_rand() . '.eml';
        $file     = $this->path . '/' . $filename;
        $email    = $message->toString();

        if (false === @\file_put_contents($file, $email)) {
            throw new \Swift_TransportException(\sprintf(
                'Unable to write mail to file (directory "%s")',
                $this->path
            ));
        }

        if ($evt) {
            $evt->setResult(\Swift_Events_SendEvent::RESULT_SUCCESS);
            $evt->setFailedRecipients($failedRecipients);
            $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed');
        }

        return $count;
    }
255507
public function send(Message $message)
    {
        $rawMessage = $this->getMessageEncoder()->encode($message) . "\0";

        // send message in one packet
        $this->socketClient->write($rawMessage);

        return 1;
    }
1075409
public function send(MessageContract $message)
    {
        $this->callSendingListener($message);

        $swiftMessage = $this->getSwiftMessage($message);

        $failedRecipients = [];

        $result = $this->newResult();

        try {
            $this->swiftMailer->send($swiftMessage, $failedRecipients);

            $result->increment();
            $result->addFailedRecipient($failedRecipients);

            $this->callSentListener($message);
        } catch (Exception $e) {
            $result->addFailedRecipient($this->guessRecipient($message), $e);
        }

        return $result;
    }
633305
protected function publishToExchange(Message $message, \AMQPExchange $exchange)
    {
        $isPublished = $exchange->publish(
            $message->getMessage(),
            $message->getRoutingKey(),
            $message->getFlags(),
            $message->getAttributes()
        );

        if (!$isPublished) {
            throw FailedToPublishException::fromMessage($message);
        }

        return $isPublished;
    }
485786
public function send(OutgoingMessage $message)
    {
        $composeMessage = $message->composeMessage();
        $from = $message->getFrom();

        foreach ($message->getTo() as $to) {
            $data = [
                'from'        => $from,
                'bulkVariant' => $this->getVariantForSender($from),
                'message'     => $composeMessage,
                'to'          => $to,
            ];

            $response = $this->sendRequest($data);

            if ($this->hasError($response)) {
                $this->handleError($response);
            }
        }
    }
989852
protected function _send($message, &$failedRecipients = null)
    {
        $swiftMessage = new \Swift_Message();

        if ($charset = $message->getCharset()) {
            $swiftMessage->setCharset($charset);
        }

        $swiftMessage->setFrom($message->getFrom() ?: $this->_from);

        if ($replyTo = $message->getReplyTo()) {
            $swiftMessage->setReplyTo($replyTo);
        }

        $swiftMessage->setTo($message->getTo() ?: $this->_to);

        if ($cc = $message->getCc()) {
            $swiftMessage->setCc($cc);
        }

        if ($bcc = $message->getBcc()) {
            $swiftMessage->setBcc($bcc);
        }

        $swiftMessage->setSubject($message->getSubject());
        $swiftMessage->setBody($message->getHtmlBody());

        if ($priority = $message->getPriority()) {
            $swiftMessage->setPriority($priority);
        }

        foreach ($message->getAttachments() as $attachment) {
            $swiftMessage->attach(
                (new \Swift_Attachment($attachment['data'], $attachment['file'], $attachment['contentType']))->setId($attachment['cid']));
        }

        return $this->_swift->send($swiftMessage, $failedRecipients);
    }
1013025
public function batchSendMessage($messages, $delay = 0)
    {
        $successCount = 0;
        foreach ($messages as $message) {
            if ($this->sendMessage($message, $delay)) {
                $successCount++;
            }
        }
        return $successCount;
    }
1085506
public function send(Message $message) : void
    {
        if ($this->destination === null) {
            $destination = $message->getDestination();
            if ($destination === null) {
                throw new \Exception('Cannot send message, no destination set.');
            }
        } else {
            $destination = $this->destination;
        }
        $relayState = $message->getRelayState();

        $msgStr = $message->toSignedXML();

        Utils::getContainer()->debugMessage($msgStr, 'out');
        $msgStr = $msgStr->ownerDocument->saveXML($msgStr);

        $msgStr = base64_encode($msgStr);

        if ($message instanceof Request) {
            $msgType = 'SAMLRequest';
        } else {
            $msgType = 'SAMLResponse';
        }

        $post = [];
        $post[$msgType] = $msgStr;

        if ($relayState !== null) {
            $post['RelayState'] = $relayState;
        }

        Utils::getContainer()->postRedirect($destination, $post);
    }
619920
private function processResultMessages(Message $message, array $recipients, $resultMessages): ResultCollection
    {
        if (is_scalar($resultMessages)) {
            $key = $this->responseParser->parse($resultMessages);

            if ($key === 'signature_not_allowed') {
                throw new SenderNameNotAllowedException(sprintf(
                    'The signature (sender) "%s" not allowed.',
                    $message->getSender()
                ));
            } elseif ($key === 'signature_invalid') {
                throw new InvalidSenderNameException(sprintf(
                    'Invalid signature (sender): %s',
                    $message->getSender()
                ));
            }

            throw new SendSmsException(sprintf(
                'Cannot resolve the error for sending SMS. Error: %s',
                $resultMessages
            ));
        }

        $sendResult = $resultMessages[0];
        $sendResultKey = $this->responseParser->parse($sendResult);

        if ($sendResultKey === 'missing_required_parameters') {
            throw new MissingRequiredParameterException('Missing required parameters.');
        }

        if ($sendResultKey !== 'success' && $sendResultKey !== 'fail') {
            throw new SendSmsException(sprintf(
                'Fail send sms. Result messages: %s',
                json_encode($resultMessages)
            ));
        }

        array_shift($resultMessages);

        $resultData = [];

        foreach ($recipients as $recipient) {
            $messageId = array_shift($resultMessages);
            $success = preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/', $messageId);

            if ($success) {
                $resultData[] = Result::successfully($recipient, $messageId);
            } else {
                $reason = $this->tryResolveErrorReason($messageId);
                $resultData[] = Result::failed($recipient, new Error($reason, $messageId));
            }
        }

        return new ResultCollection(...$resultData);
    }
894011
public function send(ShortMessageInterface $message)
    {
        for ($i = 0; $i < $this->retryCount; $i++) {
            $result = false;
            try {
                $result = $this->transport->send($message);
            } catch (DeliveryFailedException $exception) {
                if ($this->logger) {
                    $this->logger->warning($exception->getMessage());
                }
            }

            if ($result === true) {
                return true;
            }

            sleep($this->delay);
        }

        if ($this->logger) {
            $this->logger->error('Delivery try count exceeded');
        }

        return false;
    }
1019396
private function sendBcc(Swift_Mime_SimpleMessage $message, $reversePath, array $bcc, array &$failedRecipients)
    {
        $sent = 0;
        foreach ($bcc as $forwardPath => $name) {
            $message->setBcc([$forwardPath => $name]);
            $sent += $this->doMailTransaction(
                $message, $reversePath, [$forwardPath], $failedRecipients
                );
        }

        return $sent;
    }
1045638
public function send(MessageInterface $message, &$failures = null)
    {
        return $this->mailer->send($message(), $failures);
    }
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);
        }
    }
1216467
public void sendMessage(Message message) throws RemoteException
    {
        BaseTransport transport = this.createProxyTransport(SEND_MESSAGE);
        transport.addParam(MESSAGE, message);   // Don't use COMMAND
        transport.sendMessageAndGetReply();
    }
1316405
protected function sendSwiftMessage($message)
    {
        try {
            return $this->swift->send($message, $this->failedRecipients);
        } finally {
            $this->forceReconnection();
        }
    }
69021
private function sendMessage($message, $successCodes = null, $errorMsg = null, $baseEncode = false) {
		$this->log($message);
		$getResponse = (bool) $successCodes;
		if ($baseEncode) $message = base64_encode($message);
		try {
			$response = $this->connection->sendMessage($message, $getResponse, self::EOL);
		} catch (SmtpConnectionException $ex) {
			$this->log($ex->getMessage(), 'server', true);
			throw $ex;
		}
		if (!$response) return null;
		
		$successCodes = is_array($successCodes) ? $successCodes : array($successCodes);
		if (!in_array($response->getCode(), $successCodes)) {
			$this->log($response, 'server', 1);
			throw new SmtpConnectionException($errorMsg);
		}
		$this->log($response);
		
		return $response;
	}
422434
protected function streamMessage(Swift_Mime_SimpleMessage $message)
    {
        $this->buffer->setWriteTranslations(["\r\n." => "\r\n.."]);
        try {
            $message->toByteStream($this->buffer);
            $this->buffer->flushBuffers();
        } catch (Swift_TransportException $e) {
            $this->throwException($e);
        }
        $this->buffer->setWriteTranslations([]);
        $this->executeCommand("\r\n.\r\n", [250]);
    }