I have the main mail template (resources/views/mail.blade.php). This is a common template to use all of my mail like for forgot password or for change new password. The content for mail.blade.php is below:
<table>
<tr><td>SiteName</td>
</tr>
<tr><td>{{$content}}</td></tr>
</table>
I'm storing the content of email template (in mySql db) through CKEditor and it looks like:
<p>Dear {{$username}},</p>
<p>This is your new password: {{$newPassword}}</p>
Now I using mail function in laravel 5.5 as below:
$content = str_replace(array('username', 'newPassword'), array($userName, $request->confirm_password), addslashes($emailTemplate->templateBody));
Mail::send(['html' => 'mail'], ['content' => $content], function ($message) use($emailTemplate, $user){
$message->from($emailTemplate->fromEmail, $emailTemplate->fromName);
$message->to($user->email);
});
After sending email in mailtrap.io, I see the mail looks like:
SiteName
<p>Dear Niladri,</p> <p>This is your new password: 123456</p>
Please note, the table, tr, td where SiteName is written in the mail.blade is working and no HTML code is showing in the email. That's fine. But only the content from the CKEditor is showing with HTML tags (<p></p>
).
Have I did anything wrong?