select_msg_list($where); //查询所有的用户分组 $where2 = "where uid='$uid' "; $group_list = $admin->select_user_group($where2); $where3 = "where uid='$uid'"; if(!empty($_POST['group_name']) && $_POST['group_name']!='all'){ $where3.=" and group_name='{$_POST['group_name']}'"; } $customer_list = $admin->selesctCustomer($where3); $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 = $one_info['msg_title']; $content = $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; } } $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 ); //var_dump($params);exit; $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); } $info = $result['message']; header("Location:/?a=send_email2_admin&m=index&info=$info"); exit(); } $this->assign('group_list',$group_list); $this->assign('info',$info); $this->assign('template_list',$template_list); $this->display("index.html"); } // class end } ?>