我建立一个CakePHP的网站,发送电子邮件这样的:CakePHP的2.1.0:捕获电子邮件输出
$email = new CakeEmail('default');
$email->template('test');
$email->emailFormat('html');
$email->to(array('[email protected]' => '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除了实际发送电子邮件之外,还会在变量中发送电子邮件。这样,我可以在数据库中记录电子邮件正文的确切内容。这是可行的吗?
这没有奏效,但非常感谢您的时间! – Nick 2012-03-15 21:13:14
你有错误吗?那么它不起作用呢? (我从$ this-> email-> message()更改为$ email-> message()) – Dave 2012-03-15 21:16:30
(编辑答案我认为应该起作用 - 如果是这样,我会删除我的答案的第一部分) – Dave 2012-03-15 21:24:59