phpmailer群发邮件_PHP_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > PHP > phpmailer群发邮件

phpmailer群发邮件

 2013/7/10 2:36:14  x171306523c  程序员俱乐部  我要评论(0)
  • 摘要:<?phprequire_once("class.phpmailer.php");functionsmtp_mail($sendto_email,$subject,$body,$extra_hdrs,$user_name){$mail=newPHPMailer();$mail->IsSMTP();$mail->Host="mail.yourdomain.com";//$mail->SMTPDebug=2;$mail->SMTPAuth=true;$mail->
  • 标签:PHP 邮件
class="php"><?php 
require_once("class.phpmailer.php");
function smtp_mail ( $sendto_email, $subject, $body, $extra_hdrs, $user_name) {
	$mail = new PHPMailer();
	$mail->IsSMTP();
	$mail->Host       = "mail.yourdomain.com";
	//$mail->SMTPDebug  = 2;
	$mail->SMTPAuth   = true;
	$mail->SMTPSecure = "ssl";
	$mail->Host       = "smtp.gmail.com";
	$mail->Port       = 465;
	$mail->Username   = "******@gmail.com";
	$mail->Password   = "******";
	
	$mail->CharSet = "UTF-8";
	$mail->Encoding = "base64";
	
	$mail->AddAddress($sendto_email, $user_name);
	$mail->AddReplyTo("","my name is xc");
	
	$mail->IsHTML(true);
	$mail->Subject = $subject;
	
	$mail->AltBody ="text/html";
	$mail->MsgHTML($body);
	
	if($mail->Send()){
		info_write("ok.txt","$sendto_email YES");
	}else {
		info_write("falied.txt","$sendto_email NO,Notice $mail->ErrorInfo");
	}
}

function info_write($filename,$info_log){
	$info = "";
	$info.= $info_log;
	$info.="\r\n";
	$fp = fopen ($filename,'a');
	fwrite($fp,$info);
	fclose($fp);
}

function redirect($url){
	echo "<script>
	        function redirect(){
	          window.location.replace('$url');
	        }
	        window.setTimeout('redirect();', 15000);
	        </script>";
}

$filename = "email.txt";
$fp = fopen($filename,"r");
$contents = fread($fp,filesize($filename));
$list_email=explode("\r\n",$contents);
$len=count($list_email);
fclose($fp);

if (@$_GET['action']) {
	$i = $_GET['action'];
}else {
	$i = 0;
}


if ($i<$len){
	$x = $i+1;
	$rs=explode("@",$list_email[$i]);
	$user_name = $rs[0];
	echo "Sending {$x}封({$list_email[$i]}) E-mail......{$user_name}";
	smtp_mail($list_email[$i], 'Treasurery Online', "<a href=baidu.com>百度</a>", 'http://www.treasurer.org.cn/', $user_name);
	redirect("?action=$x");
	$i++;
}else {
	echo "All emails sent out!";
	exit;
}



?>

?

  • phpmail群发邮件.rar (28 KB)
  • 下载次数: 0
发表评论
用户名: 匿名