Sending e-mail in Laravel with custom HTML

后端 未结 5 921
死守一世寂寞
死守一世寂寞 2021-01-06 02:01

I need to send e-mails but I already have the HTML generated, I don\'t want to use laravel blade because I need to apply a CSS Inliner to the HTML, so this is how i generate

5条回答
  •  鱼传尺愫
    2021-01-06 02:31

    The body is not accessible from the closure.

    You can create the swift message by hand:

        $message = \Swift_Message::newInstance();
        $message->setFrom($messageToParse->template['fromEmail']);
        $message->setTo($messageToParse->to['email']);
        $message->setBody($messageToParse->body);
        $message->addPart($messageToParse->body, 'html contents');
        $message->setSubject('subject');
    

    But then you to need to create the transport:

        $mailer = self::setMailer( [your transport] );
        $response =  $mailer->send($message);
    

提交回复
热议问题