参考Demo
//参考demo /* * 发起POST网络提交 * @params string $url : 网络地址 * @params json $data : 发送的json格式数据 */ function https_post($url,$data) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); if (!empty($data)){ curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); curl_close($curl); return $output; } $data['host'] = 'smtp.qq.com';//邮件商 $data['email'] = '[email protected]';//邮箱 $data['username'] = '';//发件用户名 $data['password'] = '*****';//密码 $data['secure'] = 'tls';//安全方式 $data['post'] = '587';//端口 $data['address'] = [['email'=>'[email protected]','name'=>'test1'],['email'=>'[email protected]','name'=>'test2']];//收件人 $data['subject'] = 'ccc';//简介 $data['body'] = 'body1';//内容 $data['altbody'] = 'body';//该属性的设置是在邮件正文不支持HTML的备用显示 $ret = ['data'=>json_encode($data),'key'=>1,'pid'=>4]; $url = 'http://mctool.wangmingchang.com/api/tool/email'; $ret = https_post($url,$ret); var_dump($ret);
返回值result=1 成功成功 result=0 发送失败
{"msg":"send ok","url":"back","result":"1"}