jeudi 31 mai 2018

Laravel 5 Mail template showing html tags

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></td></tr>
</table>

I'm storing the content of email template (in mySql db) through CKEditor and it looks like:

<p>Dear ,</p>
<p>This is your new password: </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?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2LaIWmO
via IFTTT

Aucun commentaire:

Enregistrer un commentaire