Sends mail via SMTP using PhpSMTP
Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
@param string $header The message headers
@param string $body The message body
@uses SMTP
@access protected
@return bool
177288
protected function SmtpSend($header, $body) {
    require_once $this->PluginDir . 'class.smtp.php';
    $bad_rcpt = array();

    if(!$this->SmtpConnect()) {
      throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
    }
    $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
    if(!$this->smtp->Mail($smtp_from)) {
      throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
    }

    // Attempt to send attach all recipients
    foreach($this->to as $to) {
      if (!$this->smtp->Recipient($to[0])) {
        $bad_rcpt[] = $to[0];
        // implement call back function if it exists
        $isSent = 0;
        $this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
      } else {
        // implement call back function if it exists
        $isSent = 1;
        $this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
      }
    }
    foreach($this->cc as $cc) {
      if (!$this->smtp->Recipient($cc[0])) {
        $bad_rcpt[] = $cc[0];
        // implement call back function if it exists
        $isSent = 0;
        $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
      } else {
        // implement call back function if it exists
        $isSent = 1;
        $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
      }
    }
    foreach($this->bcc as $bcc) {
      if (!$this->smtp->Recipient($bcc[0])) {
        $bad_rcpt[] = $bcc[0];
        // implement call back function if it exists
        $isSent = 0;
        $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
      } else {
        // implement call back function if it exists
        $isSent = 1;
        $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
      }
    }


    if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses
      $badaddresses = implode(', ', $bad_rcpt);
      throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
    }
    if(!$this->smtp->Data($header . $body)) {
      throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL);
    }
    if($this->SMTPKeepAlive == true) {
      $this->smtp->Reset();
    }
    return true;
  }
430743
function Send() {
      if(count($this->to) < 1)
      {
         $this->error_handler("You must provide at least one recipient email address");
         return false;
      }
      // Set whether the message is multipart/alternative
      if(!empty($this->AltBody))
         $this->ContentType = "multipart/alternative";

      $header = $this->create_header();
      if(!$body = $this->create_body())
         return false;

      //echo "<pre>".$header . $body . "</pre>"; // debugging
      // Choose the mailer
      if($this->Mailer == "sendmail")
      {
         if(!$this->sendmail_send($header, $body))
            return false;
      }
      elseif($this->Mailer == "mail")
      {
         if(!$this->mail_send($header, $body))
            return false;
      }
      elseif($this->Mailer == "smtp")
      {
         if(!$this->smtp_send($header, $body))
            return false;
      }
      else
      {
         $this->error_handler(sprintf("%s mailer is not supported", $this->Mailer));
         return false;
      }
      return true;
   }
407281
protected function SmtpSend($header, $body)
    {
        //require_once $this->PluginDir . 'class.smtp.php';
        $bad_rcpt = array();

        if (!$this->SmtpConnect()) {
            throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
        }
        $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
        if (!$this->smtp->Mail($smtp_from)) {
            throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
        }

        // Attempt to send attach all recipients
        foreach ($this->to as $to) {
            if (!$this->smtp->Recipient($to[0])) {
                $bad_rcpt[] = $to[0];
            }
        }
        foreach ($this->cc as $cc) {
            if (!$this->smtp->Recipient($cc[0])) {
                $bad_rcpt[] = $cc[0];
            }
        }
        foreach ($this->bcc as $bcc) {
            if (!$this->smtp->Recipient($bcc[0])) {
                $bad_rcpt[] = $bcc[0];
            }
        }
        if (count($bad_rcpt) > 0) {
            //Create error message for any bad addresses
            $badaddresses = implode(', ', $bad_rcpt);
            throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
        }
        if (!$this->smtp->Data($header . $body)) {
            throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL);
        }
        if ($this->SMTPKeepAlive == true) {
            $this->smtp->Reset();
        }
        return true;
    }
632205
public static function sendEmail($toEmail, $subject, $body, $fromEmail)
    {
        $headers = "From: $fromEmail\r\n" .
            "Reply-To: $fromEmail\r\n" .
            "X-Mailer: PHP/" . phpversion();
        
        return mail($toEmail, $subject, $body, $headers);
    }
162046
public function publish($body, array $headers = [], $exchange = '', $routingKey = '', $mandatory = false, $immediate = false)
    {
        $response = $this->publishImpl($body, $headers, $exchange, $routingKey, $mandatory, $immediate);

        if ($this->mode === ChannelModeEnum::CONFIRM) {
            if ($response instanceof PromiseInterface) {
                return $response->then(function () {
                    return ++$this->deliveryTag;
                });
            } else {
                return ++$this->deliveryTag;
            }
        } else {
            return $response;
        }
    }
491193
protected function justSend( string$body=null )
	{
		$this->body= $body;

		if( $length= strlen($body) )
		{
			$this->header( 'Content-Length', $length );
		}

		$this->header( 'Connection', 'close' );

		$this->sendHeader();

		$this->sendBody($body);
	}
1358742
public function send($email, $name = null, $subject, $body, $attachment = null, $bcc = null)
    {
        $this->phpMailer->isSMTP();
        $this->phpMailer->Host = $this->app->config->getMail('host');
        $this->phpMailer->SMTPAuth = true;
        $this->phpMailer->Username = $this->app->config->getMail('username');
        $this->phpMailer->Password = $this->app->config->getMail('password');
        $this->phpMailer->SMTPSecure = $this->app->config->getMail('encryption');
        $this->phpMailer->Port = $this->app->config->getMail('port');

        $this->phpMailer->From = $this->app->config->getMail('from.email');
        $this->phpMailer->FromName = $this->app->config->getMail('from.name');

        $this->phpMailer->addAddress($email, $name);

        $this->phpMailer->addReplyTo(
                                $this->app->config->getMail('reply.email'),
                                $this->app->config->getMail('mail.reply.name')
                            );

        $this->phpMailer->addBCC($bcc);

        $this->phpMailer->addAttachment($attachment);

        $this->phpMailer->isHTML(true);

        $this->phpMailer->Subject = $subject;
        $this->phpMailer->Body    = $body;

        /**
         * If log set to true
         * then log email
         */
        if ($this->app->config->getMail('log') == true) return $this->logEmail($body);

        /**
         * If log set to false
         * then send email
         */
        if ( $this->app->config->getMail('log') !== true)
        {
            try
            {
                set_time_limit(0);

                if( ! $this->phpMailer->send()) throw new MailerException($this->phpMailer->ErrorInfo);

                else return true;
            }
            catch(phpmailerException  $e)
            {
                throw new MailerException($e->errorMessage());
            }
        }
    }
706338
protected function sendHeaders()
    {
        if (headers_sent()) return false;

        header(sprintf(
            'HTTP/%s %s %s',
            $this->getProtocolVersion(),
            $this->getStatusCode(),
            $this->getReasonPhrase()
        ));

        foreach ($this->getHeaderKeys() as $name)
        {
            header(sprintf('%s: %s', $name, $this->getHeaderLine($name)), true);
        }

        return true;
    }
1008547
protected function mail($to, $subject, $body, array $headers)
    {
        mail($to, $subject, $body, implode("\r\n", $headers));
    }
1103505
protected function sendBody($body):void
    {
        if (is_resource($body)) {
            fpassthru($body);
            fclose($body);
        }
        else {
            echo $body;
        }
    }
413033
public function send()
    {
        if (!static::isSent()) {
            static::call('send', $this);
            foreach ($this->headers as $header => $value) {
                $this->setHttpHeader($header, $value);
            }
            http_response_code($this->status);
            echo $this->body;
            static::$sent = true;
            return true;
        }
        return false;
    }
557937
private function sendPostRequest(array $body)
    {
        $requestBodyKey = version_compare(ClientInterface::VERSION, '6.0', '>=') ? 'form_params' : 'body';
        $response = $this->httpClient->post('', [
            $requestBodyKey => $body,
        ]);

        return \json_decode($response->getBody(), true);
    }
688075
public function send($send_headers = false)
	{
		$body = $this->__toString();

		if ($send_headers)
		{
			$this->send_headers();
		}

		if ($this->body != null)
		{
			echo $body;
		}
	}
951265
function smtp_send($helo, $from, $to, $header, $body = "")
    {
        if (!$this->smtp_putcmd("HELO", $helo)) {
            return $this->smtp_error("sending HELO command");
        }
        #auth
        if ($this->auth) {
            if (!$this->smtp_putcmd("AUTH LOGIN", base64_encode($this->user))) {
                return $this->smtp_error("sending HELO command");
            }

            if (!$this->smtp_putcmd("", base64_encode($this->pass))) {
                return $this->smtp_error("sending HELO command");
            }
        }
        if (!$this->smtp_putcmd("MAIL", "FROM:<" . $from . ">")) {
            return $this->smtp_error("sending MAIL FROM command");
        }

        if (!$this->smtp_putcmd("RCPT", "TO:<" . $to . ">")) {
            return $this->smtp_error("sending RCPT TO command");
        }

        if (!$this->smtp_putcmd("DATA")) {
            return $this->smtp_error("sending DATA command");
        }

        if (!$this->smtp_message($header, $body)) {
            return $this->smtp_error("sending message");
        }

        if (!$this->smtp_eom()) {
            return $this->smtp_error("sending <CR><LF>.<CR><LF> [EOM]");
        }

        if (!$this->smtp_putcmd("QUIT")) {
            return $this->smtp_error("sending QUIT command");
        }
        return TRUE;
    }
886165
protected function send(
        ResponseInterface $response,
        string $body): ResponseInterface
    {
        if (!$body) {
            $response = $this->sendErrorDocument($response);
        }
        unset($this->errorDocument);
        $response = $response->withHeader(
            Response::HEADER_CONTENT_LENGTH,
            (string) strlen($body));
        header(Response::PROTOCOL
             . $response->getProtocolVersion() . " "
             . $response->getStatusCode() . " "
             . $response->getReasonPhrase());
        foreach ($response->getHeaders() as $key => $value) {
            header($key . ": " . implode("; ", $value));
        }
        $response->getBody()->write($body);
        return $response;
    }
345664
public function delete($url, $headers = [], $body = null)
    {
        return $this->send(Method::DELETE, $url, $body, $headers);
    }
1208843
function mail_send($header, $body) {
      //$to = substr($this->addr_append("To", $this->to), 4, -2);

      // Cannot add Bcc's to the $to
      $to = $this->to[0][0]; // no extra comma
      for($i = 1; $i < count($this->to); $i++)
         $to .= sprintf(",%s", $this->to[$i][0]);

      if ($this->Sender != "" && PHP_VERSION >= "4.0")
      {
         $old_from = ini_get("sendmail_from");
         ini_set("sendmail_from", $this->Sender);
      }

      if ($this->Sender != "" && PHP_VERSION >= "4.0.5")
      {
         // The fifth parameter to mail is only available in PHP >= 4.0.5
         $params = sprintf("-f %s", $this->Sender);
         $rt = @mail($to, $this->Subject, $body, $header, $params);
      }
      else
      {
         $rt = @mail($to, $this->Subject, $body, $header);
      }

      if (isset($old_from))
         ini_set("sendmail_from", $old_from);

      if(!$rt)
      {
         $this->error_handler("Could not instantiate mail()");
         return false;
      }

      return true;
   }