How to use different markdown template layout for another Mailable in Laravel

Sometime happen that we need absolutely different layouts for newsletters and subscription email and at the same time use the Laravel’s built-in markdown templating.

In this case the solution is very simple, just change the default markdown mailable resource path on the fly in the Mailable class:

class NewsletterCampaignMail extends Mailable {

    // ...

    public function build() {
        config(['mail.markdown.paths' => [resource_path('views/vendor/mail-newsletter')]]);

        // ...
    }
}

Leave a Reply