求教 fsockopen 并发。
我想发邮件 不知道 fsockopen 这个怎么并发邮件
------解决方案--------------------
你可以ajax循环执行发送邮件,也可以用下面两个方法(西面代码是大致思路):
- PHP code
if (isset($_GET['act']) && $_GET['act'] == 'sendMail') { sendEmail();// 发送邮件操作}function fSockGet($url, $timeout = 3){ $info = parse_url($url); extract($info); $query = isset($query) ? trim($query) : ''; $path = isset($path) ? trim($path) : ''; $fp = fsockopen($host, 80, $errno, $errstr, $timeout); if (!$fp) { exit("$errstr ($errno)<br>\n"); } $write = fwrite($fp, "GET {$path}?{$query} HTTP/1.0\r\nHost: {$host}\r\n\r\n");// while (!feof($fp)) {// echo fread($fp, 4096);// }}$url = "http://mydir.com/index.php?act=sendMail";$emailList = array(...);foreach ($emailList as $email) { fSockGet($url);}