本教程是借用其他服务器群发邮件!所以不存在被封!
以下是使用联合早报的地址发送的!- <?php
- header("Content-type:image/png");
- //header("Content-Type: image/jpeg");
- //readfile('logo.jpg');
- $count_num=0;
- //如果存放计数器文件已经存在,读取其中的内容
- if(file_exists("counter.txt")){
- $fp=fopen("counter.txt","r");
- $count_num=0+fgets($fp,9);
- $count_num++;
- fclose($fp);
- }
- $fp=fopen("counter.txt","w");
- fputs($fp,$count_num);
- fclose($fp);
- $fromname= file_get_contents("fromname.txt");//邮件标题
- $eml= file_get_contents("eml.txt");//邮件内容
- $content = file_get_contents("qq.txt");//邮件地址
- $content = str_replace( "\r", "", $content );
- $content = preg_split( "/\\n/", $content, -1, PREG_SPLIT_NO_EMPTY );
- $qq= $content[$count_num];
- //echo "<h2 align=center>正在发送第{$count_num}封{$qq}邮件。。。。。</h2>";
- function fcontents($url,$post_data)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_URL,$url);
- //为了支持cookie
- curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
- curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
- $fcontents = curl_exec($ch);
- return $fcontents;
- }
- $post_data = array();
- $post_data['toMail'] = "$qq";
- $post_data['fromName'] = "{$fromname}#@qq.com";
- //$post_data['fromMail'] = "[email protected]";
- $post_data['content'] = "$eml";
- $post_data['submit'] = "submit";
- $o="";
- foreach ($post_data as $k=>$v)
- {
- $o.= "$k=".urlencode($v)."&";
- }
- $post_data=substr($o,0,-1);
- $body=fcontents('http://www.zaobao.com//asianet/recommend/send_news03.pl',$post_data);
- function baby($url){
- $ch = curl_init();
- curl_setopt ($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
- $baby = curl_exec($ch);
- //$fcontents =iconv("UTF-8", "gb2312//IGNORE",curl_exec($ch));
- return $baby;
- }
- $url = 'https://my.frantech.ca/cart.php?a=add&pid=67';//监控buyvm
- $con = baby($url);
- $BuyVM = "BuyVM";
- $ok = "有货";
- $no = "无货";
- $lost= count($content)-$count_num;
- $email="邮件还剩{$lost}封";
- $email2="正在发送{$qq}";
- //$font = "/usr/share/fonts/chinese/TrueType/uming.ttf"; //字体设置部分linux和windows的路径可能不同
- $font = "/usr/share/fonts/chinese/TrueType/SimHei.ttf"; //字体设置部分linux和windows的路径可能不同
- $im = imagecreate(120,120);
- $white = imagecolorallocate($im,128,64,225);
- $black = imagecolorallocate($im,255,255,255);
- if (preg_match("/Out of Stock/i", $con)) {
- imagettftext($im,15,0,10,20,$black,$font,$BuyVM);
- imagettftext($im,15,0,70,20,$black,$font,$no);
- imagettftext($im,10,0,2,40,$black,$font,$email);
- imagettftext($im,8,0,1,60,$black,$font,$email2);
- } else {
- imagettftext($im,15,0,10,20,$black,$font,$BuyVM);
- imagettftext($im,15,0,70,20,$black,$font,$ok);
- imagettftext($im,10,0,2,40,$black,$font,$email);
- }
- imagepng($im);
- ?>
复制代码 |