Send mail similar to the PHP mail function

@param  string|array $to
@param  string       $subject
@param  string       $data
@param  array        $headers
@return mixed
338128
public static function raw($to, $subject, $data, array $headers = [])
    {
        if (!is_array($to)) {
            $to = [$to];
        }

        $message = new Message();

        $message->toList($to)->subject($subject)->setMessage($data);

        foreach ($headers as $key => $value) {
            $message->addHeader($key, $value);
        }

        return static::$instance->send($message);
    }
818879
public function send($to, $subject, $message, $from = 'default', $headerExtra = [], $html = true) {
        if (!is_null($this->method)) { // if a method is set then use that one
            if (is_string($this->method) && ('swift' == $this->method)) {
                return $this->_swiftMail($to, is_string($from) ? $this->from[$from] : $from, $subject, $message, [], $html);
            } else {
                return call_user_func($this->method, $to, is_string($from) ? $this->from[$from] : $from, $subject, $message, [], $headerExtra, $html);
            }
        } // if not use default
        return $this->_mail($to, is_string($from) ? $this->from[$from] : $from, $subject, $message, [], $headerExtra, $html);
    }
705882
public function send($subject, $content, $data = [], callable $callback = null)
    {
        $this->driver->subject($subject)->content($content, $data);

        if (null !== $callback) {
            $callback($this->driver);
        }

        return $this->driver->send();
    }
731049
public function send($recipients, $subject, $body, $sender)
    {
        $transport = \Swift_SmtpTransport::newInstance();
        $mailer = \Swift_Mailer::newInstance($transport);

        $message = \Swift_Message::newInstance($subject)
            ->setFrom($sender)
            ->setTo($recipients)
            ->setBody($body)
        ;

        $mailer->send($message);

        return $this;
    }
742670
protected function respondWithSuccessMessage($data = [], $headers = [])
    {
        $response = [];
        $response['success'] = true;

        if (!empty($data)) {
            $response['response'] = $data;
        }

        return $this->respond($response, $headers);
    }
1084294
public function email($email, $subject = null, $body = null) {
	    $email = 'mailto:'.$email;
	    if (!is_null($subject) || !is_null($body)) {
	        $email .= '?'.http_build_query(compact('subject', 'body'));
        }
	    return $this->encode($email);
    }
718837
public function send(
        array $data,
        MembershipInterface $sender,
        MembershipInterface $receiver,
        MessageParticipantModelInterface $replyTo = null // TODO: Check if this should be Message instead
    ): PodiumResponse
    {
        $sending = $this->getMessenger();

        $sending->setSender($sender);
        $sending->setReceiver($receiver);
        $sending->setReplyTo($replyTo);

        if (!$sending->loadData($data)) {
            return PodiumResponse::error();
        }

        return $sending->send();
    }
1207109
public function serialize($subject, &$data = array(), SerializerInterface $serializer = null)
    {
        $context = $this->serializer();
        $context($subject, $data, $serializer);
        return $data;
    }
1067117
protected function getDefaultMessage($from, $encoding, $to, $subject, $body) {
        if(is_string($from)) {
            $from = array('email' => $from, 'name' => $from);
        }

        $message = new MailMessage();
        $message->setFrom($from['email'], $from['name'])
            ->setEncoding($encoding)
            ->setSubject($subject)
            ->setBody($body)
            ->setTo($to);

        return $message;
    }
288482
private function sendEmail($to = '', $subject = '', $messageText = '')
    {
        $transport = $this->getServiceLocator()->get('mail.transport');
        $message = new Message();
            
        $message->addTo($to)
                ->addFrom($this->getOptions()->getSenderEmailAdress())
                ->setSubject($subject)
                ->setBody($messageText);

        $transport->send($message);
    }
311917
protected function sendEmailNotification($subject, $message)
    {
        $superUsers = UsersManagerApi::getInstance()->getUsersHavingSuperUserAccess();

        foreach ($superUsers as $superUser) {
            $mail = new Mail();
            $mail->setDefaultFromPiwik();
            $mail->addTo($superUser['email']);
            $mail->setSubject($subject);
            $mail->setWrappedHtmlBody($message);
            $mail->send();
        }
    }
925241
protected function sendEmail($email,$subject,$message)
	{
		$headers=$this->getHeaders();
		if($this->utf8)
		{
			$headers[]="MIME-Version: 1.0";
			$headers[]="Content-Type: text/plain; charset=UTF-8";
			$subject='=?UTF-8?B?'.base64_encode($subject).'?=';
		}
		if(($from=$this->getSentFrom())!==null)
		{
			$matches=array();
			preg_match_all('/([^<]*)<([^>]*)>/iu',$from,$matches);
			if(isset($matches[1][0],$matches[2][0]))
			{
				$name=$this->utf8 ? '=?UTF-8?B?'.base64_encode(trim($matches[1][0])).'?=' : trim($matches[1][0]);
				$from=trim($matches[2][0]);
				$headers[]="From: {$name} <{$from}>";
			}
			else
				$headers[]="From: {$from}";
			$headers[]="Reply-To: {$from}";
		}
		mail($email,$subject,$message,implode("\r\n",$headers));
	}
1038465
public function createMessage(string $subject, string $to, string $template, array $data = [])
    {
        $message = new Swift_Message();

        $message->setSubject($subject);
        $message->setTo($to);

        $tpl = pathinfo(basename($template), PATHINFO_FILENAME);

        $htmlBody = null;
        try {
            $htmlBody = $this->templateEngine->render(sprintf('%s.html', $tpl), $data);
            // @codeCoverageIgnoreStart
        } catch (RuntimeException $e) {
            // @codeCoverageIgnoreEnd
        }

        $txtBody = null;
        try {
            $txtBody = $this->templateEngine->render(sprintf('%s.txt', $tpl), $data);
            // @codeCoverageIgnoreStart
        } catch (RuntimeException $e) {
            // @codeCoverageIgnoreEnd
        }

        if ($htmlBody && $txtBody) {
            $message->setBody($htmlBody, 'text/html');
            $message->addPart($txtBody, 'text/plain');
        } else {
            if ($htmlBody) {
                $message->setBody($htmlBody, 'text/html');
            } else {
                $message->setBody($txtBody, 'text/plain');
            }
        }

        return $message;
    }
734243
public function send(string $subject, string $message): void
    {
        $this->getMailer()
            ->send(
                $this->getMessage($subject, $message)
            )
        ;
    }
726639
function SendmailSend($header, $body) {
    if ($this->Sender != "")
    $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
    else
    $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));

    if(!@$mail = popen($sendmail, "w"))
    {
      $this->SetError($this->Lang("execute") . $this->Sendmail);
      return false;
    }

    fputs($mail, $header);
    fputs($mail, $body);

    $result = pclose($mail) >> 8 & 0xFF;
    if($result != 0)
    {
      $this->SetError($this->Lang("execute") . $this->Sendmail);
      return false;
    }

    return true;
  }
916928
public function send(
        $from_name,
        array $receivers,
        &$successfulRecipients,
        &$failedRecipients,
        $subject = '',
        $body = '',
        $content_type = 'text/html',
        $charset = 'UTF-8'
    )
    {
        $mailer = \Swift_Mailer::newInstance($this->transport);
        $message = \Swift_Message::newInstance();
        $message->setFrom([$this->_username => $from_name]);
        $message->setTo($receivers);
        $message->setSubject($subject);
        $message->setBody($body, $content_type, $charset);
        $successfulRecipients = $mailer->send($message, $failedRecipients);
        return true;
    }
473186
public static function sendMail($recipient, $subject = null, $html, $c = null)
    {
        $c = self::toArray($c);
        $headers = 'From: ' . stripslashes($c['exp_nom']) . ' <' . $c['exp_mail'] . '>' . "\r\n";
        $headers .= 'MIME-version: 1.0' . "\n";
        $headers .= 'Content-type: text/html; charset=UTF-8' . "\n";
        $headers .= 'Reply-To: ' . $c['exp_mail'] . "\r\n";
        $success = mail($recipient, '=?UTF-8?B?' . base64_encode($subject) . '?=', stripslashes($html), $headers);

        return $success;
    }