php - cakephp 3.x : can we use emailformat='both' without using template -


while sending email using emailformat='both' sending email without using template.

$email->reset(); $email->emailformat('both'); $email->to($to); $email->send($body); 

in original email not getting plain text :-

--alt-82207de3b13b81a697e6c7c6db145af2 content-type: text/plain; charset=utf-8 content-transfer-encoding: 8bit  <div>​<br>hi<br><br>soon reach action limit. keep updated please pay payment.<br><br> happy to&nbsp; have you<br><br>thanks,<br>kioui apps team<br>​</div>   --alt-82207de3b13b81a697e6c7c6db145af2 content-type: text/html; charset=utf-8 content-transfer-encoding: 8bit  <div>​<br>hi<br><br>soon reach action limit. keep updated please pay payment.<br><br> happy to&nbsp; have you<br><br>thanks,<br>kioui apps team<br>​</div> 

cakephp not offer such functionality out of box.

theoretically should able achieve without templates using own custom render (view) class ignores templates , transforms content.

however that's kinda hacky, way easier create 2 basic templates not add content on own, echo/transform $content view var, hold whatever pass cakeemail::send().

a simple example:

emails/html/template-name.ctp

echo $content; 

emails/text/template-name.ctp

echo html_entity_decode(strip_tags($content), ent_quotes, configure::read('app.encoding')); 

note basic example should demonstrate concept, not proper html text conversion in way, should use/build dedicated html text converter sanitizes , transforms input!

see example converting html plain text in php e-mail


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -