我正在构建一个发送电子邮件的 CakePHP 网站,如下所示:
$email = new CakeEmail('default');
$email->template('test');
$email->emailFormat('html');
$email->to(array('john_doe@example.com' => 'John Doe'));
$email->subject('Test E-mail');
$email->helpers(array('Html', 'Text'));
$email->viewVars(
array(
...
)
);
if ($email->send()) {
$this->Session->setFlash('The e-mail was sent!', 'default', array('class' => 'alert alert-success'));
}
else {
$this->Session->setFlash('An unexpected error occurred while sending the e-mail.', 'default', array('class' => 'alert alert-error'));
}
除了实际发送电子邮件之外,我还希望能够在变量中捕获电子邮件呈现的 HTML。这样,我可以在数据库中记录电子邮件正文的确切内容。这是可行的吗?