0
我想从CakePHP控制器发送电子邮件与当前正在添加的帖子的网址。我需要找到帖子的ID,以便它可以传递给视图函数,但我不知道这一点?CakePHP发送电子邮件与最近发布的网址
即,
function add() {
if (!empty($this->data)) {
//var_dump($this->data);
//die();
$file_path = $this->Attachment->upload($this->data['Post'],'img');
//$this->Attachment->thumbnail($this->data['Post']['img'], 'attachments/files_dir', '250', '250', $crop = 'resize');
if ($this->Post->save($this->data)) {
$this->sendTemplateHtmlMail();
$this->Session->setFlash('Your post has been saved.');
$this->redirect(array('action' => 'index'));
}
}
}
function sendTemplateHtmlMail($recipientemail, $to) {
$this->Email->to = '[email protected]';
$this->Email->subject = 'Cake test template email';
$this->Email->replyTo = '[email protected]';
$this->Email->from = 'Cake Test Account <[email protected]>';
$this->Email->template = 'test2';
//Send as 'html', 'text' or 'both' (default is 'text')
$this->Email->sendAs = 'html';
//Set view variables as normal
$this->set('recipientemail',);
//Do not pass any args to send()
if ($this->Email->send()) {
$this->Session->setFlash('Template html email sent');
} else {
$this->Session->setFlash('Template html email not sent');
}
// $this->redirect('/');
}
所以我添加/保存后,然后发送电子邮件到收件人,在电子邮件我想要的只是增加帖子的网址,我如何通过帖子的ID,如果我不知道它呢?
感谢
是的!真棒。谢谢 – benhowdle89 2011-06-15 22:08:23
不客气。如果我回答了您的问题,请“接受”它。 – 2011-06-15 22:11:46
老兄,我有3,980点,我知道如何接受答案:)只是等待时间限制解除 – benhowdle89 2011-06-15 22:13:24