Send the message.  If MAILER_RESULT_FAIL is returned, use GetErrors() to
determine the problem.

@param EmailMessage $message
@return int results of operation (MAILER_RESULT_OK | MAILER_RESULT_FAIL)
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;
    }
965809
public function send($message)
    {
        try {
            $code = 200;
            $this->sendEvent($this->targetServiceName, $message);
            $message = 'Event has been sent';
        } catch (\Exception $exception) {
            $message = $exception->getMessage();
            $code = $exception->getCode();
        }

        return new Response(
            json_encode(['message' => $message]),
            (!empty($code)) ? $code : 500
        );
    }
568182
public function send(Message $message)
	{
		// Queue the message and flush the associated gateway
		$messageEnvelope = $this->queue($message);
		$this->flush( $message->getCertificate() );

		// Return the envelope
		return $messageEnvelope;
	}
482668
public function send(Message $message)
    {
        $transport = $this->getTransport();
        if ($transport == false) {
            throw new \common_exception_InconsistentData('Transport strategy not correctly set for '.__CLASS__);
        }
        return $this->getTransport()->send($message);
    }
29381
public function send(Message $message)
    {
        if (empty($message->getTo()) || empty($message->getSubject()) || empty($message->getMessage())) {
            throw new InvalidArgumentException(
                "An error has occurred. The sender or the message or object omits.",
                E_USER_ERROR
            );
        }

        if (isset($this->config['mail'])) {
            $section = $this->config['mail']['default'];

            if (!$message->fromIsDefined()) {
                $form = $this->config['mail'][$section];

                $message->from($form["address"], $form["username"]);
            } elseif (!Str::isMail($message->getFrom())) {
                $form = $this->config['mail'][$message->getFrom()];

                $message->from($form["address"], $form["username"]);
            }
        }

        $to = '';

        $message->setDefaultHeader();

        foreach ($message->getTo() as $value) {
            if ($value[0] !== null) {
                $to .= $value[0] . ' <' . $value[1] . '>';
            } else {
                $to .= '<' . $value[1] . '>';
            }
        }

        $headers = $message->compileHeaders();

        $headers .= 'Content-Type: ' . $message->getType() . '; charset=' . $message->getCharset() . Message::END;

        $headers .= 'Content-Transfer-Encoding: 8bit' . Message::END;

        // Send email use the php native function
        $status = @mail($to, $message->getSubject(), $message->getMessage(), $headers);

        return (bool) $status;
    }
82936
public static function send(IMailMessage $mail) {
        $success = TRUE;
        try {
            mail($mail->getTo(), $mail->getSubject(), $mail->getBody(), $mail->getHeaders());
        } catch (Exception $exc) {
            $success = FALSE;
        }
        return $success;
    }
860970
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
    {
        return $this->getMailer()->send($message, $failedRecipients);
    }
309831
public function send($carrier, $phoneNumber, $subject, $message, $split = FALSE)
		{
			// Check for valid Carrier
			$carriers = $this->getCarriers();
			if (empty($carriers[$carrier])) {
				return 0;
			}

			// Clean up the phone number
			$phoneNumber = str_replace([' ', '-'], '', $phoneNumber);

			// Calculate the prefix and suffix
			// If separator is not found that means its a suffix
			list($prefix, $suffix) = strpos($carriers[$carrier], $this->prefixSuffixSeparator) !== FALSE
				?
				explode($this->prefixSuffixSeparator, $carriers[$carrier])
				:
				['', $carriers[$carrier]];

			// Calculate Address
			$to = "{$prefix}{$phoneNumber}@{$suffix}";

			// Calculate message
			// Result in an array of count 1
			$messages = $split ? $this->splitMessage($message, $this->splitLength) : [$message];

			// Send Email
			$successCount = 0;
			foreach ($messages as $message) {
				$successCount += $this->_mail($to, $subject, $message);
			}

			return $successCount;
		}
1024134
public function send($message, &$failedRecipients = null)
    {
        if ($this->_log) {
            $this->filesystem->fileAppend($this->_log, json_encode($message, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . PHP_EOL);
        }

        $this->logger->debug(['From: ', $message->getFrom()]);
        $this->logger->debug(['To: ', $message->getTo()]);
        $this->logger->debug(['Cc:', $message->getCc()]);
        $this->logger->debug(['Bcc: ', $message->getBcc()]);
        $this->logger->debug(['Subject: ', $message->getSubject()]);

        $failedRecipients = [];

        $message->setMailer($this);
        $this->eventsManager->fireEvent('mailer:beforeSend', $this, ['message' => $message]);
        $r = $this->_send($message, $failedRecipients);
        $this->eventsManager->fireEvent('mailer:afterSend', $this, ['message' => $message, 'failedRecipients' => $failedRecipients]);

        return $r;
    }
928325
public function sendMessage($message)
    {
        $message = sprintf("%s\r\n", $message);
        fwrite($this->getSocketStream(), $message, strlen($message));
        return $this->receiveMessage();
    }
1313234
public function publish(string $message): int
    {
        return $this->handle->publish($this->name, $message);
    }
582329
private function checkMessageStatus($message)
    {
        if (!$message || $message->success == 0 || $message->failure > 0) {
            throw new DispatchMessageException(
                sprintf("%d messages could not be processed", $message->failure)
            );
        }
    }
740589
public function send(MessageInterface $message, $skipErrors = true) {
        $this->clearErrors();

        $command = $this->prepareCommand($message->getText());

        foreach ($message->getRecipient() as $recipient) {
            // execute command
            $command = str_replace('#RECIPIENT#', $recipient, $command);

            $return = 0;
            $output = [];
            exec($command, $output, $return);

            if ($return !== 0) {
                $errorMsg = sprintf("Error while sending message to \"%s\".", $recipient);
                $this->addError(new SendingError($recipient, self::ERROR_NOT_SAVED, $errorMsg));
                if (!$skipErrors) {
                    throw new RuntimeException($errorMsg, self::ERROR_NOT_SAVED);
                }
            }
        }
        return $this->getErrors()->count() === 0;
    }
1363344
protected function _send($message)
    {
        $options = [
            'headers' => ['Authorization' => 'Bearer ' . $this->getConfig('api_key')]
        ];
        $response = $this->http->post('/api/mail.send.json', $message, $options);
        if ($response->getStatusCode() !== 200) {
            throw new SendgridEmailException(sprintf(
                'SendGrid error %s %s: %s',
                $response->getStatusCode(),
                $response->getReasonPhrase(),
                implode('; ', $response->json['errors'])
            ));
        }

        return $response->json;
    }
985222
def send_messages(self, email_messages):
        
        if not email_messages:
            return
        sent = self._send(email_messages)
        if sent:
            return len(email_messages)
        return 0
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)
            ]
        );
    }
1316405
protected function sendSwiftMessage($message)
    {
        try {
            return $this->swift->send($message, $this->failedRecipients);
        } finally {
            $this->forceReconnection();
        }
    }