我正在尝试通过使用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();
}
}请帮帮我,它快把我逼疯了!
发布于 2013-03-28 16:47:35
在这个函数中似乎没有设置$data,所以我猜测它依赖于MY_Controller中的会话或其他东西来填充它--这在CLI中是不可用的
如果看不到代码的其余部分,就不能准确地告诉您,但是您应该能够从中跟踪它
https://stackoverflow.com/questions/15668782
复制相似问题