Search code examples
phplaravel-5html-emailemail-templates

Sending HTML email templates using Laravel


I have created a file with name dummy.blade.php which has the following code

<!DOCTYPE html>
 <html lang="en-EN">
  <head>
    <meta charset="utf-8">
  </head>
  <body bgcolor="#11C9FF">
   {{$emailBody}}
  </body>
 </html>

And I am trying to send HTML content using:

 Mail::send('emailTemplates.dummy', ['emailBody'=>'<h1>TESTING</h1>'], function($message)
 {
 $message->to($myEmail)->subject('Password reset');
 });

And the email received is like this:

enter image description here

As per documentation that I should be receiving the html format but I am receiving simple text based email. Any clues?


Solution

  • Just posting the answer as that could be useful for others. changed

      {{$emailBody}}
    

    to

      <?= $emailBody ?>
    

    and it worked like a charm.