我正在尝试使用codeigniter通过cron作业运行每周电子邮件更新。如果我在浏览器中检查它,一切正常,但是当我通过命令行运行它时,它会循环一次,然后在将$ message变量设置为视图时死掉。
日志不会显示任何有用的内容
记录信息
DEBUG - 2013-03-27 20:26:35 --> Email Class Initialized
DEBUG - 2013-03-27 20:26:35 --> File loaded: /email_templates/weekly_user_update.php
DEBUG - 2013-03-27 20:26:36 --> Language file loaded: language/english/email_lang.php
有问题的代码
public function weekly_update(){
$this->load->model('statistics_model','stats');
$this->load->library('email');
$config['mailtype'] = "html";
$this->email->initialize($config);
$users = $this->stats->get_product_users();
echo "Found ".count($users)." user(s).==".PHP_EOL;
echo "--Beginning User Parse--".PHP_EOL;
$count= 0;
foreach($users as $user){
echo " Parsing User ".$user['first_name']." ".$user['last_name']."[".$user['user_id']."]".PHP_EOL;
$this->email->to($user['email']);
$subject = "Weekly Updates for ".date('m/d/Y');
$this->email->subject($subject);
$message = $this->load->view('email_templates/weekly_user_update',$data,TRUE);
$this->email->message($message);
echo " Sending Message to ".$user['email']." '".$subject."'".PHP_EOL;
$this->email->send();
echo " Weekly Update Sent to {$to}!".PHP_EOL;
$this->email->clear();
}
}
请帮助它让我疯了!
答案 0 :(得分:0)
$ data似乎没有设置在这个函数的任何地方,所以我猜它依赖于会话或MY_Controller中的某个东西来填充它 - 这在CLI中是不可用的
如果没有看到其余的代码,就无法准确地告诉您,但您应该可以从中跟踪它