这是蛋糕代码.....注意$email_body
<?php
$this->Email->reset();
$this->Email->delivery = 'smtp';
$this->Email->smtpOptions = array(
'port'=>'465',
'timeout'=>'30',
'host' => 'ssl://smtp.gmail.com',
'username'=>'noreply@example.com',
'password'=>'a_password_you_cant_see',
);
$this->Email->sendAs = 'html';
$this->Email->template = 'default';
$this->Email->from = '"NO-REPLY" <noreply@example.com>';
$this->Email->to = "rakib@example.com";
$this->Email->subject = "test PHP html email";
$email_body = "Hello message body
<hr />
This is rakib
<br />
<table width=\"100%\" bgcolor=\"#ff0\">
<tr>
<td>
In a table
</td>
</tr>
</table>";
$this->Email->send($email_body);
?>
Show Original
发送这封电子邮件后,当我通过GMail 下拉菜单中的按钮 [在电子邮件的右上角]查看原始邮件内容时,HTML 如下所示:
<!-- Starting to render - email/html/default -->
<p> Hello message body</p>
<p> <hr /></p>
<p> This is rakib</p>
<p> <br /></p>
<p> <table width="100%" bgcolor="#ff0"></p>
<p> <tr></p>
<p> <td></p>
<p> In a table</p>
<p> </td></p>
<p> </tr></p>
<p> </table></p>
<p> </p>
<!-- Finished - email/html/default -->
<p>
并且</p>
每个新行都包含标签.....这是为什么?使用 CakePHP 1.3