Sending e-mail in Laravel with custom HTML

后端 未结 5 919
死守一世寂寞
死守一世寂寞 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:30

    I want to share a tip which might help sending emails without "blade".

    Laravel Mail function is actually a wrapper for Swift. Just assign empty arrays to $template and $data, I mean the first 2 parameters of the function, then do the rest inside callback.

    Mail::send([], [], function($message) use($to, $title, $email_body)
    {
        $message->setBody($email_body)->to($to)->subject($title);
    });
    

提交回复
热议问题