{@inheritdoc}

@param string $to      The recipient, email or something handled by ReciepientCaster
@param string $subject
@param string $body    The text body

@return \Ems\Contracts\Mail\Message
168563
public function message($to = '', $subject = '', $body = '')
    {
        $message = $this->transport->newMessage();

        if ($to) {
            $message->to($to);
        }
        if ($subject) {
            $message->subject($subject);
        }
        if ($body) {
            $message->body($body);
        }

        $message->setMailer($this);

        return $message;
    }
179938
protected function sendMessage($to, $subject, $view, $params = [])
    {
        /** @var \yii\mail\BaseMailer $mailer */
        $mailer = Yii::$app->mailer;
        $mailer->viewPath = $this->viewPath;
        $mailer->getView()->theme = Yii::$app->view->theme;

        return $mailer->compose(['html' => $view, 'text' => 'text/' . $view], $params)
            ->setTo($to)
            ->setFrom([$mailer->transport->getUsername() => \Yii::$app->name ?? Url::to(['/'], true)])
            ->setSubject($subject)
            ->send();
    }
433292
public AwsSesSendResult sendEmail(
      @Nonnull final String to,
      @Nonnull final String from,
      @Nonnull final String subject,
      @Nonnull final String body) {
    return proxy.sendEmail(to, from, subject, body);
  }
113827
public function subject($subject = null)
    {
        deprecationWarning('Email::subject() is deprecated. Use Email::setSubject() or Email::getSubject() instead.');

        if ($subject === null) {
            return $this->getSubject();
        }

        return $this->setSubject($subject);
    }
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);
    }
750258
public static function mail_to($email, $text = null, $subject = null, $attr = array())
	{
		$text or $text = $email;

		$subject and $subject = '?subject='.$subject;

		return html_tag('a', array(
			'href' => 'mailto:'.$email.$subject,
		) + $attr, $text);
	}
414192
public void sendMail (String to, String subject, String content) throws MessagingException {
        Properties props = new Properties();
        props.put("mail.smtp.user", emailConfg.getUser());
        props.put("mail.smtp.host", emailConfg.getHost());
        props.put("mail.smtp.port", emailConfg.getPort());
        props.put("mail.smtp.starttls.enable","true");
        props.put("mail.smtp.debug", emailConfg.getDebug());
        props.put("mail.smtp.auth", emailConfg.getAuth());
        props.put("mail.smtp.ssl.trust", emailConfg.host);

        SMTPAuthenticator auth = new SMTPAuthenticator(emailConfg.getUser(), (String)secret.get(SecretConstants.EMAIL_PASSWORD));
        Session session = Session.getInstance(props, auth);

        MimeMessage message = new MimeMessage(session);

        message.setFrom(new InternetAddress(emailConfg.getUser()));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));

        message.setSubject(subject);

        message.setContent(content, "text/html");

        // Send message
        Transport.send(message);
        if(logger.isInfoEnabled()) logger.info("An email has been sent to " + to + " with subject " + subject);
    }
359881
public function getMessage(array $to, $from_email, $from_name, $subject, $message_body, array $attachments, $mail_type='html')
    {
        $message = \Swift_Message::newInstance();
        $message->setTo($to);
        if ($attachments) {
            foreach ($attachments as $attachment) {
                foreach ($attachment as $file => $alt_name) {
                    if ($alt_name == '') {
                        $message->attach(\Swift_Attachment::fromPath($file));
                    } else {
                        $message->attach(\Swift_Attachment::fromPath($file)->setFilename($alt_name));
                    }
                }
            }
        }
        
        $message->setFrom($from_email, $from_name);
        $message->setSubject($subject);
        if ($mail_type == 'html') {
            $message->setBody($message_body, 'text/html');
        } else {
            $message->setBody($message_body);
        }
        
        return $message;
    }
676236
protected static function createMessage(string $to, string $subject, string $from = 'default'): Swift_Message
    {
        $fromName = $from === 'default' ? self::$config['from']['default'] : $from;
        $from     = self::$config['from'][$fromName];

        return (new Swift_Message())
            ->setContentType('text/html')
            ->setSubject($subject)
            ->setFrom([$from['address'] => $from['name']])
            ->setTo($to)
            ;
    }
1178698
public static function sendGenericEmail($email, $subject, $bodyHtml, $bodyHtmlAlt = '')
    {
        $mail = self::getNewMailer($email);
        $mail->WordWrap = 50; // Set word wrap to 50 characters
        $mail->isHTML(true); // Set email format to HTML
        $mail->Subject = $subject;
        $mail->Body = $bodyHtml;
        $mail->AltBody = $bodyHtmlAlt;
        return $mail->send();
    }
711852
protected function renderEmail(
        $subject,
        $receiverEmail,
        array $context = []
    ) {
        $message = Swift_Message::newInstance()
            ->setSubject($subject)
            ->setFrom($this->fromEmail)
            ->setTo($receiverEmail)
            ->setContentType('text/html')
            ->setBody(
                $this->templatingEngine->render(
                    $this->template,
                    array_merge(
                        $context,
                        ['layout' => $this->layout]
                    )
                )
            );

        $this
            ->mailer
            ->send($message);

        return $this;
    }
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);
    }
572551
public function send($to)
    {
        // will throw exception
        $this->testValidateMessageParts();

        $message = $this->createMessage($to);

        return $this->mailManager->send($message);
    }
1008547
protected function mail($to, $subject, $body, array $headers)
    {
        mail($to, $subject, $body, implode("\r\n", $headers));
    }
519083
public function createMessage($subject = null, $body = null, $contentType = null, $charset = null)
    {
        $message = Swift_Message::newInstance($subject, $body, $contentType, $charset);

        if(null !== $this->fromEmail) {
            
            if(null === $this->fromName) {
                $message->setFrom($this->fromEmail);
            } else {
                $message->setFrom($this->fromEmail, $this->fromName);
            }
            
        }

        return $message;
    }
172296
public function sendHtml ($subject, $contentHTML, $to, $cc=array(), $bcc=array())
    {
        $mail = $this->phpMailer;

        // Ensure if all destination specifications are arrays
        if (!is_array($to )) { $to  = array($to)  ; }
        if (!is_array($cc )) { $cc  = array($cc)  ; }
        if (!is_array($bcc)) { $bcc = array($bcc) ; }

        // Add all recipients
        foreach ($to as $toAddr => $toName) {
            if (is_numeric($toAddr)) {
                $toAddr = $toName;
            }
            $mail->addAddress($toAddr, $toName);
        }

        foreach ($cc as $ccAddr => $ccName) {
            if (is_numeric($ccAddr)) {
                $ccAddr = $ccName;
            }
            $mail->addCC($ccAddr, $ccName);
        }

        foreach ($bcc as $bccAddr => $bccName) {
            if (is_numeric($bccAddr)) {
                $bccAddr = $bccName;
            }
            $mail->addBCC($bccAddr, $bccName);
        }


        // Content
        $mail->Subject = $subject;
        $mail->msgHTML($contentHTML);
        $mail->AltBody = strip_tags(nl2br($contentHTML));

        // Send the message, check for errors
        if (!$mail->send()) {
            throw new Exception("Mail Error: " . $mail->ErrorInfo . "\n");
        }
    }
680990
protected function sendNewEmailSimple($body, $subject, $emailTo = '', 
        $emailID = -3, $treeID = -3, $coreID = -3, $userTo = -3)
    {
        $emaTo = [];
        if (is_array($emailTo)) {
            $emaTo = $emailTo;
            $emailTo = $emailTo[1] . ' <' . $emailTo[0] . '>';
        } elseif (trim($emailTo) != '') {
            $emaUsr = User::where('email', $emailTo)->first();
            if ($emaUsr && isset($emaUsr->name)) {
                $emaTo[] = [$emailTo, $emaUsr->name];
            }
        }
        if ($GLOBALS["SL"]->isHomestead()) {
            echo '<div class="container"><h2>' . $subject . '</h2>' . $body . '<hr><hr></div>';
        } else {
            $this->sendEmail($body, $subject, $emaTo);
        }
        return $this->logEmailSent($body, $subject, $emailTo, $emailID, $treeID, $coreID, $userTo);
    }