Laravel - Mail - Generating Markdown Mailables
To generate a mailable with a corresponding Markdown template, you may use the --markdown
option of the make:mail
Artisan command:
php artisan make:mail OrderShipped --markdown=emails.orders.shipped
Then, when configuring the mailable within its build
method, call the markdown
method instead of the view
method. The markdown
method accepts the name of the Markdown template and an optional array of data to make available to the template:
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from('[email protected]')
->markdown('emails.orders.shipped', [
'url' => $this->orderUrl,
]);
}