Reputation: 332
I am sending htmlmail using CakeEmail in myproject. I use a table structure in my email layout file and saved my replaceable text in database. The Mail function works fine, it add the database content to the email layout before send. But the table layout is breaking when I receive the mail. I found out the render function in CakeEmail.php adds <p>
tags to each line of code which I saved in database.
(int) 32 => ' <table align="center" border="0" cellspacing="0" cellpadding="0" >',
(int) 33 => ' <tbody> <tr><td><p> <tr></p>',
(int) 34 => '<p> <td style="padding:0;margin:0;"></p>',
(int) 35 => '<p> <h2 style="color:#404040;font-size:24px;font-weight:bold;line-height:22px;padding:0;margin:0;letter-spacing:0.015 em; font-family: arial,sans-serif;">Activate Account</h2></p>',
(int) 36 => '<p> </td></p>',
(int) 37 => '<p> </tr></p>',
(int) 38 => '<p> </p>',
(int) 39 => ' <tr><td></tbody>',
(int) 40 => ' </table>',
How can I send replace the database text without the <p>
element.
Database entry is like this
<table style="margin-top: 80px" width="630" align="center" border="0" cellspacing="0" cellpadding="0" > <tbody> <tr><td style="padding:0;margin:0;"> <h2 style="color:#404040;font-size:24px;font-weight:bold;line-height:22px;padding:0;margin:0;letter-spacing:0.015 em; font-family: arial,sans-serif;">Activate Account</h2> </td></tr></tbody> </table>
Upvotes: 0
Views: 239
Reputation: 60463
Lines are wrapped in <p>
elements in the default HTML email element template, which can be found in app/View/Emails/html/default.ctp
:
$content = explode("\n", $content);
foreach ($content as $line):
echo '<p> ' . $line . "</p>\n";
endforeach;
https://github.com/cakephp/cakephp/blob/2.3.0/app/View/Emails/html/default.ctp
Modify the template to your needs, probably you just want to echo $content;
.
Upvotes: 2