简体   繁体   中英

Laravel mailables dynamic view treat as blade

does it possible to do:

Create Mailable class in my package and use it to Mail::send(new MyMaiable($config))

In my config will also html template saved in database.

My question is does it any way to use this html string as blade template

I mean {{$var}} will replace without manually str_replace or preg_replace_all but by ->with([]) method.

Environment

  • php 5.6
  • Laravel 5.4

Thanks in advance for any hints.

Why are you storing the html template in your database? Save the template in your resources->emails folder as a blade template and call it in the mailable class like this:

public function build()
{
    return $this->from('YOUR_FROM_EMAIL')
        ->view('emails.TEMPLATE_NAME');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM