app/Mail.php
public static function send(UserInterface $from, UserInterface $to, UserInterface $reply_to, $subject, $message_text, $message_html): bool
    {
        try {
            $message_text = preg_replace('/\r?\n/', "\r\n", $message_text);
            $message_html = preg_replace('/\r?\n/', "\r\n", $message_html);

            $message = (new Swift_Message($subject))
                ->setFrom($from->email(), $from->realName())
                ->setTo($to->email(), $to->realName())
                ->setReplyTo($reply_to->email(), $reply_to->realName())
                ->setBody($message_html, 'text/html')
                ->addPart($message_text, 'text/plain');

            $mailer = new Swift_Mailer(self::transport());
            $mailer->send($message);
        } catch (Exception $ex) {
            Log::addErrorLog('Mail: ' . $ex->getMessage());

            return false;
        }

        return true;
    }
public static function send(UserInterface $from, UserInterface $to, UserInterface $reply_to, $subject, $message_text, $message_html): bool
    {
        try {
            $message_text = preg_replace('/\r?\n/', "\r\n", $message_text);
            $message_html = preg_replace('/\r?\n/', "\r\n", $message_html);

            $message = (new Swift_Message($subject))
                ->setFrom($from->email(), $from->realName())
                ->setTo($to->email(), $to->realName())
                ->setReplyTo($reply_to->email(), $reply_to->realName())
                ->setBody($message_html, 'text/html')
                ->addPart($message_text, 'text/plain');

            $mailer = new Swift_Mailer(self::transport());
            $mailer->send($message);
        } catch (Exception $ex) {
            Log::addErrorLog('Mail: ' . $ex->getMessage());

            return false;
        }

        return true;
    }
public static function send ( UserInterface $ from , UserInterface $ to , UserInterface $ reply_to , $ subject , $ message_text , $ message_html ) : bool { try { $ message_text = preg_replace ( '/\r?\n/' , "\r\n" , $ message_text ) ; $ message_html = preg_replace ( '/\r?\n/' , "\r\n" , $ message_html ) ; $ message = ( new Swift_Message ( $ subject ) ) -> setFrom ( $ from -> email ( ) , $ from -> realName ( ) ) -> setTo ( $ to -> email ( ) , $ to -> realName ( ) ) -> setReplyTo ( $ reply_to -> email ( ) , $ reply_to -> realName ( ) ) -> setBody ( $ message_html , 'text/html' ) -> addPart ( $ message_text , 'text/plain' ) ; $ mailer = new Swift_Mailer ( self :: transport ( ) ) ; $ mailer -> send ( $ message ) ; } catch ( Exception $ ex ) { Log :: addErrorLog ( 'Mail: ' . $ ex -> getMessage ( ) ) ; return false ; } return true ; }
Send an external email message
Caution! gmail may rewrite the "From" header unless you have added the address to your account.

@param UserInterface $from
@param UserInterface $to
@param UserInterface $reply_to
@param string        $subject
@param string        $message_text
@param string        $message_html

@return bool
Send an external email message Caution! gmail may rewrite the From header unless you have added the address to your account .