CodeIgniter Forums
Parser, HTML visible and Email - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Parser, HTML visible and Email (/showthread.php?tid=76745)



Parser, HTML visible and Email - ryanUGLE - 06-15-2020

Hello,

I have a series of templates set up in my view directory.

When sending an email, i load the template by:
PHP Code:
$message $parser->setData($data)->parse($template_name); 


I then send that to an email wrapper which does the same task, only with

PHP Code:
$data[
...
'content' => $message


When sending the email (with mail_type = 'html') I receive all the text (HTML tags and all).
When printing the email (to see what would be sent), $message displays tags.

I am obviously using this wrong or missing something, i'm having trouble where i'm messing it up.

Thanks, Ryan


RE: Parser, HTML visible and Email - ryanUGLE - 06-16-2020

If anyone comes across this with the same issue, i had to do the following:



PHP Code:
//SEE EDIT, this is left for reference. This line does not include 'raw' anymore
//See 'raw', where no escaping occurs.
$this->setData($data'raw')->render('templates/email/base');
//END SEE EDIT 

Edit:
I believe this would escape all the data, which for your usage it may vary. I have amended my 'email/base' template 'content' tag to {!content!}.
This escapes the 'content' data assignment but not the others.


RE: Parser, HTML visible and Email - jayson.s - 12-08-2020

Thanks for this info, very helpful! keep it up!