Doaa Magdy Doaa Magdy - 1 year ago 85
HTML Question

Laravel 5 Use standard view as an email template

I've a Laravel 5.0 project, that I need to send emails to users (such as registration confirmation mail, ... etc).

My problem is I want to create a view (that contains the header and footer of my App), and I want to use this view's html output as a template for the email message body (I need HTML output so I can get Full URLs for images and links to be sent in the email body).

My Question is, Is there any method that can work like curl, when I pass the view URL, This method grab the HTML source of this view?

I don't want to use custom packages for that, I need a native solution

Answer Source

Create basic email template in resources/views/mails/template.blade.php

header html...


footer html...

And then in particular emails, for example resources/views/mails/confirmation.blade.php


    content of confirmations email...

To store html of rendered view in a variable you can do

$view = View::make('mails.confirmation');
$html = $view->render();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download