array("email"=>"lxk8875@yahoo.com","logistics_number"=>"888888","uname"=>"hcm"), // "2" => array("email"=>"hcmdd888@hotmail.com","logistics_number"=>"888888","uname"=>"hcm"), // ); //end $count = count($customer_list);//发送数量 if($secret!=$getSecret){ //密钥有误 echo 1;exit; } if(empty($store_name)){ //没传店铺名; echo 2;exit; } if($type!=1 && $type!=2){ //发送主题,1是询问收货地址;2确认收货 echo 3;exit; } global $EMAIL_MSG_LIST; global $EMAIL_SUBJECT_LIST; $subject = $EMAIL_SUBJECT_LIST[$store_name][$type]; $admin = new AdvertAdminAction(); //alipearlhair $info = $admin->selectUserByName($store_name); $api_user = $info['api_user']; $api_key = $info['api_key']; $from = $info['email_from']; $replyto = $info['email'];//发件人邮箱地址 $content = $EMAIL_MSG_LIST[$store_name][$type]; $post_url = 'http://api.sendcloud.net/apiv2/mail/send'; //假设一次只能给100个人发,看需要发几次 $c = 100; $p = ceil($count/100);//需要发总次数 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'][] = $list['email']; $user_name = $list['uname']; $x_smtpapi['sub']['%name%'][] = $user_name; if($type==1){ $x_smtpapi['sub']['%address%'][] = $list['address']; } if($type==2){ $x_smtpapi['sub']['%logistics_number%'][] = $list['logistics_number']; } } } $x_smtpapi = json_encode($x_smtpapi); $params = array( 'apiUser' => $api_user, 'apiKey' => $api_key, 'xsmtpapi' => $x_smtpapi, 'from' => $from, 'subject' => $subject, 'html' => $content, 'replyto' => $replyto ); $result = make_curl($post_url,$params); //插入 普通邮件发送日志表 $params['uid'] = $info['id']; $params['message'] = $result['message']; $params['time'] = time(); $params['to'] = $params['xsmtpapi']; $insert_log = $admin->inserEmail1Log($params); } $msg = $result['message']; //成功 echo 5;exit; } }