phpmailer

2021/8/17 9:36:40

本文主要是介绍phpmailer,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

  1. <?php 
  2. @session_start();  
  3.  include(dirname(__FILE__).'./inc/function.php'); 
  4.  require(dirname(__FILE__)."/mail/class.phpmailer.php");  
  5.  $array =  array_unique(Get_value('mail',1)); 
  6.  $type = Get_value('type',1); 
  7.   
  8.  $mail = new PHPMailer();  
  9.  $count =0;  
  10.  $bad =0; 
  11.  $mail->IsSMTP();                                      // set mailer to use SMTP 
  12.  $mail->Host = "smtp.163.com";  // smtp1.example.com;smtp2.example.comspecify main and backup server 
  13.  $mail->SMTPAuth = true;     // turn on SMTP authentication 
  14.  $mail->Username = "mailangel123";  // SMTP username 
  15.  $mail->Password = "******"; // SMTP password 
  16.   
  17.  $mail->From = "mailangel123@163.com"; 
  18.  $mail->FromName = "你的好友来信"; 
  19.  $MailBody = GetContent($type); 
  20.  //$array =explode('|',$rs['mail']); 
  21.  foreach( $array as $tmpmail ){ 
  22.   if( @preg_match("/w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*/",$tmpmail) 
  23.    || strlen($User_Mail)<6 ) 
  24.   { 
  25.    $mail->AddReplyTo("mailangel123@163.com", "44"); 
  26.    $mail->AddAddress($tmpmail,'您好!'); 
  27.    $mail->WordWrap = 50; 
  28.    $mail->CharSet="GB2312";                                  
  29.    //$mail->AddAttachment("/var/tmp/file.tar.gz");         
  30.    //$mail->AddAttachment("/tmp/image.jpg", "new.jpg");    
  31.    $mail->IsHTML(true);                             
  32.     
  33.    $mail->Subject = "你的朋友邀请你一起合影!"; 
  34.    $mail->Body    = $MailBody; 
  35.     
  36.    if(!$mail->Send()) 
  37.    { 
  38.       $bad++; 
  39.       $mail->ClearAddresses();    
  40.       $mail->ClearAttachments();  
  41.        
  42.    } 
  43.    else 
  44.    { 
  45.     $count++; 
  46.    } 
  47.   } 
  48.   ShowMsg("result:$count"); 
  49.    
  50.  } 
  51. 下面这个文章是读取html 文档并进行html发送哦, 
  52.   
  53.  function GetContent($type){ 
  54.   if( $type ) 
  55.   { 
  56.    if(file_exists('./mail_room.html') ) 
  57.    { 
  58.     $content = file_get_contents( './mail_room.html'); 
  59.    } 
  60.    else 
  61.    { 
  62.     ShowMsg('file can' read fail '); 
  63.    } 
  64.   } 
  65.   else 
  66.   { 
  67.    if( file_exists( './mail_person.html') ) 
  68.    { 
  69.     $content = file_get_contents( './mail_person.html'); 
  70.    } 
  71.    else 
  72.    { 
  73.     ShowMsg('person file read fail!'); 
  74.    } 
  75.     
  76.   } 
  77.   return $content; 
  78.  } 
  79.  /* echo "<script>alert('发关".$count."邮件成功');</script>"; */ 
  80. ?> 


这篇关于phpmailer的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程