示例#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;
     }
 }
示例#2
0
 public function index()
 {
     /**
      * 邮件消息加入队列(即时邮件)
      * 
      * @param mixed $to
      * @param mixed $subject
      * @param mixed $message
      * @param mixed $from
      * @return void
      */
     $add_mail_task = Crond::get_instance('mysql')->add_mail_task('*****@*****.**', 'test mail task', 'test mail message', '*****@*****.**');
     var_dump($add_mail_task);
     echo "<hr/>";
     exit;
     /**
      * 邮件消息加入队列(定时邮件)
      * 
      * @param mixed $to
      * @param mixed $subject
      * @param mixed $message
      * @param mixed $from
      * @param mixed $interval_time
      * @param mixed $exec_time
      * @return void
      */
     $add_mail_crond = Crond::get_instance('mysql')->add_mail_crond('*****@*****.**', 'test mail task', 'test mail message', '*****@*****.**', 60, '2010-11-30 12:00:12');
     var_dump($add_mail_crond);
     echo "<hr/>";
     /**
      * url触发加入队列(即时触发)
      * 
      * @param mixed $url
      * @param mixed $smtp
      * @return void
      */
     $add_url_task = Crond::get_instance('mysql')->add_url_task('http://74.207.242.41:80/put/test');
     var_dump($add_url_task);
     echo "<hr/>";
     /**
      * url触发加入队列(定时触发)
      * 
      * @param mixed $url
      * @param mixed $interval_time
      * @param mixed $exec_time
      * @param mixed $smtp
      * @return void
      */
     $add_url_crond = Crond::get_instance('mysql')->add_url_crond('http://74.207.242.41:80/put/test', 60, '2010-11-30 12:00:12');
     var_dump($add_url_crond);
     exit('1');
 }
示例#3
0
 /**
  * 发送邮件
  * @param string $to 接收人
  * @param string $subject 主题
  * @param string $message 邮件内容
  * @param string $from_emial 发送邮件邮箱
  * @param stiring $headers 邮件头
  * @return boolean
  */
 public static function send($to = '', $subject = '', $message = '', $from_email = '', $headers = NULL)
 {
     if (empty($to) || empty($subject) || empty($message)) {
         return false;
     }
     if (self::$is_smtp) {
         $task_id = Crond::get_instance(self::$crond_drive)->add_mail_task($to, $subject, $message, $from_email);
         if ($task_id > 0) {
             return true;
         } else {
             return false;
         }
     } else {
         return Phpmail::instance()->smtp_send_mail($to, $subject, $message);
         //return Mail_z::instance()->smtp_send_mail($to, $subject, $message);
     }
 }