select_msg_list($where); //查询所有的用户分组 $where2 = "where uid='$uid' "; $group_list = $admin->select_user_group($where2); /*if(!empty($_POST['group_name']) && $_POST['group_name']!='all'){ $where3.=" and group_name='{$_POST['group_name']}'"; } $customer_list = $admin->selesctCustomer($where3);*/ /*if(!empty($_POST['group_name']) && $_POST['group_name']!='all'){ $where3.=" and group_name='{$_POST['group_name']}'"; $customer_list = $admin->selesctCustomer($where3); }elseif(!empty($_POST['group_name']) && $_POST['group_name']=='all'){ $customer_list = $admin->selesctCustomer($where2); } $count = count($customer_list); //假设一次只能给100个人发,看需要发几次 $c = 100; $p = ceil($count/100);//需要发总次数*/ $where3 = "where uid='$uid'"; if(!empty($_POST['group_name'])){ if($_POST['group_name'] != 'all'){ $where3.=" and group_name='{$_POST['group_name']}'"; $customer_list = $admin->selesctCustomer($where3); }elseif($_POST['group_name'] == 'all'){ $customer_list = $admin->selesctCustomer($where2); } $count = count($customer_list); //假设一次只能给100个人发,看需要发几次 $c = 100; $p = ceil($count/100); } if($_POST['template_id']){ $id = $_POST['template_id']; $one_info = $admin->select_one_template($id); $subject = str_replace("'", '', $one_info['msg_title']); $content = str_replace("'", '', $one_info['msg_content']); $replyto = $_SESSION['user_infos']['email'];//发件人邮箱地址 for($i=1;$i<=$p;$i++){ $min = $c*($i-1); /*$max = $c*$i;*/ $x_smtpapi = array(); /*foreach($customer_list as $key=>$list){ if($key>=$min && $key<$max){ $x_smtpapi['to'][] = trim($list['email']); $user_name = $list['uname']; $x_smtpapi['sub']['%name%'][] = $user_name; } }*/ //start $customer_list_now = array_slice($customer_list, $min, $c); foreach($customer_list_now as $key=>$list){ $x_smtpapi['to'][] = trim($list['email']); $user_name = str_replace("'", '', $list['uname']); $x_smtpapi['sub']['%name%'][] = $user_name; } //end /*$x_smtpapi = json_encode($x_smtpapi); $x_smtpapi = str_replace("\ufeff","",$x_smtpapi); $x_smtpapi = str_replace("\u00a0","",$x_smtpapi);*/ $params = array( 'apiUser' => $api_user, 'apiKey' => $api_key, 'xsmtpapi' => $x_smtpapi, 'from' => $from, 'subject' => $subject, 'html' => $content, 'fromName' => $fromName, 'replyto' => $replyto, 'uid' => $uid ); /*$result = make_curl($post_url,$params); //插入 普通邮件发送日志表 $params['uid'] = $uid; $params['message'] = $result['message']; $params['time'] = time(); $params['to'] = $params['xsmtpapi']; $insert_log = $admin->inserEmail1Log($params);*/ //start $params_arr[] = $params; //end } $datetime = empty($_POST['demo_datetime']) ? date("Y-m-d H:i:s", time()) : $_POST['demo_datetime']; //start $result = $admin->add_email_data_queue($params_arr, $datetime); if($result){ $info = '邮件已进入待发送队列'; }else{ $info = '邮件发送失败'; } //end header("Location:/?a=send_email2_admin&m=index&info=$info"); exit(); } $email = $admin->selectEmailTmpData(); $this->assign('email_counts', $email[0]['ct']); $this->assign('group_list',$group_list); $this->assign('info',$info); $this->assign('template_list',$template_list); $this->display("index.html"); } // class end } ?>