Start sending mail

@param  Message $message
@return bool
@throws SocketException
@throws ErrorException
429613
public function send(Message $message)
    {
        $this->connection();

        $error = true;

        // SMTP command
        if ($this->username !== null) {
            $this->write('MAIL FROM: <' . $this->username . '>', 250);
        } else {
            if ($message->getFrom() !== null) {
                $this->write('MAIL FROM: <' . $message->getFrom() . '>', 250);
            }
        }

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

            $this->write('RCPT TO: ' . $to, 250);
        }

        $this->write('DATA', 354);
        $data = 'Subject: ' . $message->getSubject() . Message::END;
        $data .= $message->compileHeaders();
        $data .= 'Content-Type: ' . $message->getType() . '; charset=' . $message->getCharset() . Message::END;
        $data .= 'Content-Transfer-Encoding: 8bit' . Message::END;
        $data .= Message::END . $message->getMessage() . Message::END;
        $this->write($data);

        try {
            $this->write('.', 250);
        } catch (SmtpException $e) {
            echo $e->getMessage();
        }

        $status = $this->disconnect();

        if ($status == 221) {
            $error = false;
        }

        return (bool) $error;
    }
18511
public function send(Mail\Message $message)
    {
        $consumer = new Consumer();
        $consumer->setUrl($this->config['url']);

        $params = array(
            'to' => urlencode($this->config['to']),
            'subject' => urlencode($message->getSubject()),
            'from' => urlencode($message->getFrom()->current()->getEmail()),
            'fromname' => urlencode($message->getFrom()->current()->getName()),
            'text' => urlencode($message->getBodyText()),
            'api_user' => urlencode($this->config['user']),
            'api_key' => urlencode($this->config['key']),
        );

        $bcc = $message->getBcc()->current();
        if($bcc) {
            $params['bcc'] = $bcc->getEmail();
        }

        $consumer->setParams($params);
        $consumer->setResponseType('json');
        $consumer->setCallType('get');

        return $consumer->doApiCall();

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

        foreach ($message->getTo() as $to) {
            $response = $this->plivo->send_message([
                'dst'  => $to,
                'src'  => $from,
                'text' => $composeMessage,
            ]);

            if ($response['status'] != 202) {
                $this->SMSNotSentException($response['response']['error']);
            }
        }
    }
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);
    }
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;
    }
850049
protected function sendMail(Message $mail): bool
    {
        $allRecipients = $mail->getTo() + $mail->getCc() + $mail->getBcc();
        $totalNumberOfRecipients = count($allRecipients);
        $actualNumberOfRecipients = 0;
        $exceptionMessage = '';

        try {
            $actualNumberOfRecipients = $mail->send();
        } catch (\Exception $e) {
            $exceptionMessage = $e->getMessage();
            if ($this->logSendingErrors === self::LOG_LEVEL_LOG) {
                $this->systemLogger->logException($e);
            } elseif ($this->logSendingErrors === self::LOG_LEVEL_THROW) {
                throw $e;
            }
        }

        $emailInfo = [
            'recipients' => array_keys($mail->getTo() + $mail->getCc() + $mail->getBcc()),
            'failedRecipients' => $mail->getFailedRecipients(),
            'subject' => $mail->getSubject(),
            'id' => (string)$mail->getHeaders()->get('Message-ID')
        ];
        if (strlen($exceptionMessage) > 0) {
            $emailInfo['exception'] = $exceptionMessage;
        }

        if ($actualNumberOfRecipients < $totalNumberOfRecipients && $this->logSendingErrors === self::LOG_LEVEL_LOG) {
            $this->systemLogger->log(
                sprintf('Could not send an email to all given recipients. Given %s, sent to %s', $totalNumberOfRecipients, $actualNumberOfRecipients),
                LOG_ERR, $emailInfo);
            return false;
        }

        if ($this->logSendingSuccess === self::LOG_LEVEL_LOG) {
            $this->systemLogger->log('Email sent successfully.', LOG_INFO, $emailInfo);
        }
        return true;
    }
544118
public function send(Message $message)
    {
        $em = $this->getEventManager();
        $event = $this->getEvent();
        $event->setMessage($message);
        $event->setName(SenderEvent::EVENT_SEND_PRE);
        $em->triggerEvent($event);
        $this->transport->send($message);
        $event->setName(SenderEvent::EVENT_SEND_POST);
        $em->triggerEvent($event);
    }
377101
public function send()
    {

        if ($this->Logger->isEnabled()) {
            if($this->mailer->IsError())
                $this->Logger->debug("ERROR OCCURRED");

            $this->Logger->debug("Headers:\n".$this->mailer->CreateHeader());
            $this->Logger->debug("Body:\n".$this->mailer->CreateBody());
        }

        if (!$this->testingOnly) {
            try {
                $this->mailer->Send();
            } catch (phpmailerException $e) {
                throw new EmailException($e->getMessage(), $e->getCode());
            }

        }
        return true;
    }
974235
protected function send($message)
	{
		$message = $this->encodeMessage($message);
		$this->ws->send($message);
	}
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;
    }
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;
    }
522237
protected function sending(Message $message)
    {
        $phpMailer = new PHPMailer();
        $phpMailer->isSendmail();

        // 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->addErrors([
                $phpMailer->ErrorInfo,
            ]);

            return false;
        }

        return true;
    }
267823
public function send(OutgoingMessage $message)
    {
        $messageToSend = $message->serialize();
        $length = strlen($messageToSend);
        $this->logger->debug(
            '------ Sending: ------ ' . "\n" . $messageToSend . '----------'
        );
        $this->lastActionId = $message->getActionId();
        if (@fwrite($this->socket, $messageToSend) < $length) {
            throw new ClientException('Could not send message');
        }
        $read = 0;
        while ($read <= $this->rTimeout) {
            $this->process();
            $response = $this->getRelated($message);
            if ($response != false) {
                $this->lastActionId = false;
                return $response;
            }
            usleep(1000); // 1ms delay
            if ($this->rTimeout > 0) {
                $read++;
            }
        }
        throw new ClientException('Read timeout');
    }
1276873
public function send(PHPMailer $mail)
    {
        if ($template = $this->getOption('subjectTemplate')) {
            /** @var string $template */
            $mail->Subject = Translator::translate($template, $mail->Subject);
        }

        if (!$mail->send()) {
            // Why you don't use "Exception mode" of PHPMailer
            // Because we need our Exception in any case
            throw new MailerException('Error mail send: ' . $mail->ErrorInfo);
        }

        return true;
    }
58678
public function onMessage(string $message, string $address, SocketInterface $socket)
    {
        try {
            $this->dispatch(Events::MESSAGE, new MessageEvent($socket, $address, $message));
            $socket->send($this->handleQueryFromStream($message), $address);
        } catch (\Exception $exception) {
            $this->dispatch(Events::SERVER_EXCEPTION, new ServerExceptionEvent($exception));
        }
    }
700200
public function beginEmergency(string $message, array $context = []) {
        return $this->begin(LogLevel::EMERGENCY, $message, $context);
    }
907085
public function publish($channel, $message) {
        try {
            return $this->getRedis()->publish($channel, $message);
        } catch (RedisException $ex) {
            throw new ConnectException();
        }
    }