Example #1
0
 /**
  * 邮件消息加入队列(定时邮件)
  * 
  * @param mixed $to
  * @param mixed $subject
  * @param mixed $message
  * @param mixed $from
  * @param mixed $smtp
  * @param mixed $interval_time
  * @param mixed $exec_time
  * @return void
  */
 public function add_mail_crond($to, $subject, $message, $from, $interval_time, $exec_time)
 {
     /* 得到smtp的配置信息 */
     $crond = new Crond();
     $smtp = $crond->get_smtp();
     $email_task = $this->db->from('email_task')->set(array('username' => $smtp['username'], 'password' => $smtp['password'], 'host' => $smtp['host'], 'port' => $smtp['port'], 'from' => $from, 'recipient' => $to, 'title' => $subject, 'message' => $message, 'add_time' => gmdate('Y-m-d H:i:s')))->insert();
     $insert_id = $email_task->insert_id();
     if ($insert_id <= 0) {
         Kohana::log('error', 'MAIL CROND CAN NOT INSERT. SMPT:' . print_r($smtp, true));
         return 0;
     } else {
         $crond_queue = $this->db->from('crond_queue')->set(array('task_id' => $insert_id, 'category' => 0, 'interval_time' => $interval_time, 'exec_time' => $exec_time, 'add_time' => gmdate('Y-m-d H:i:s')))->insert();
         return $insert_id;
     }
 }