CakeEmail 在使用主题时错误地报告缺少模板
CakeEmail is erroneously reporting that a template is missing when using themes
我有一个控制器 QuickContacts
,其操作 add()
使用 CakeEmail
发送消息,如下所示:
$Email = new CakeEmail();
$Email->from(array('noreply@xyz' => 'xyz'));
$Email->to(($this->isBranded) ? $this->brandedAccount['BrandedAccount']['contact_us_email'] : EMAIL_TO_MAIL_ADDRESS);
$Email->subject(EMAIL_QUICK_CONTACTS_SUBJECT);
$Email->emailFormat('html')->template('add', 'default');
$Email->message($this->request->data);
$Email->send();
当我尝试发送邮件时,我收到一条错误消息,指出视图文件不存在:
Missing View
Error: The view for QuickContactsController::add() was not found.
Confirm you have created the file: Emails/html/add.ctp in one of the following paths:
/var/www/html/mysite/app/View/Themed/Xyz/Emails/html/add.ctp
我当然可以确认这些文件存在,但出于某种原因,CakePHP 仍然无法找到它们,而且我无法弄清楚为什么会发生这种情况。谁能指出我正确的方向?
您必须在 CakeEmail
中明确设置主题:
$Email->theme('xyz')
如 Cookbox 2.x 中所述:Sending Templated Emails。
错误消息将您指向正确的路径,但 CakePHP 正在寻找您的文件:
/app/Emails/html/add.ctp
这可能是由于错误。
我有一个控制器 QuickContacts
,其操作 add()
使用 CakeEmail
发送消息,如下所示:
$Email = new CakeEmail();
$Email->from(array('noreply@xyz' => 'xyz'));
$Email->to(($this->isBranded) ? $this->brandedAccount['BrandedAccount']['contact_us_email'] : EMAIL_TO_MAIL_ADDRESS);
$Email->subject(EMAIL_QUICK_CONTACTS_SUBJECT);
$Email->emailFormat('html')->template('add', 'default');
$Email->message($this->request->data);
$Email->send();
当我尝试发送邮件时,我收到一条错误消息,指出视图文件不存在:
Missing View
Error: The view for QuickContactsController::add() was not found.
Confirm you have created the file: Emails/html/add.ctp in one of the following paths:
/var/www/html/mysite/app/View/Themed/Xyz/Emails/html/add.ctp
我当然可以确认这些文件存在,但出于某种原因,CakePHP 仍然无法找到它们,而且我无法弄清楚为什么会发生这种情况。谁能指出我正确的方向?
您必须在 CakeEmail
中明确设置主题:
$Email->theme('xyz')
如 Cookbox 2.x 中所述:Sending Templated Emails。
错误消息将您指向正确的路径,但 CakePHP 正在寻找您的文件:
/app/Emails/html/add.ctp
这可能是由于错误。