我在Cakephp 2.4.5上,如何使用/导入CakeEmail函数,以便在我的Shell脚本中使用它们?我到处找遍了,却找不到答案。大多数例子都是关于从Controller而不是Shell发送电子邮件。
此Shell由Cron作业执行。
我试过以下几种方法:
class EmailShell extends AppShell {
//App::uses('CakeEmail', 'Network/Email'); ///Results in Error: Parse error: syntax error, unexpected 'App' (T_STRING),
//App::import('Component', 'Email'); //Results in Error: Parse error: syntax error, unexpected 'App' (T_STRING),
$tasks = array('Email'); //Results in Error: [0m Task class EmailTask could not be found.
public function main () {
//email sending logic here
}发布于 2014-07-02 12:07:39
App::uses语句必须高于类开始:
App::uses('CakeEmail', 'Network/Email');
class EmailShell ...然后,您可以在这个文件类中的任何地方使用它:
$Email = new CakeEmail();
...https://stackoverflow.com/questions/24523699
复制相似问题