点击(此处)折叠或打开

  1. <?php
  2.     require_once ('class.phpmailer.php');
  3.     //发送Email函数
  4.     function smtp_mail($sendto_email, $subject, $body,$extra_hdrs, $user_name){
  5.         $mail = new PHPMailer();
  6.         $mail->IsSMTP();
  7.         $mail->Host="smtp.163.com";
  8.         $mail->SMTPAuth = true;
  9.         $mail->Username = "name" //SMTP username,普通邮件认证部需要加@域名
  10.         $mail->Password = "123456";
  11.         $mail->From = "[email protected]"
  12.         $mail->FromName="XX网站";
  13.         $mail->CharSet="GB2312";
  14.         $mail->Encoding = "base64";
  15.         $mail->AddAddress($sendto_email,$user_name); //$user_name可省略
  16.         $mail->AddReplyTo("[email protected]","XX科技公司"); //回复给[email protected]邮箱

  17.         $mail->wordwrap = 50;
  18.         $mail->AddAttachment("/var/tmp/file.tgz"); //附件1
  19.         $mail->AddAttachment("/tmp/image.jpg","new.jpt"); //附件2

  20.         $mail->IsHTML(true);
  21.         $mail->Subject = $subject;
  22.         $mail->Body = <<<EOT
  23.         <html>
  24.         <head>
  25.         <meta http-equiv="Content-Language" c>
  26.         <meta http-equiv="Content-Type" c>
  27.         </head>
  28.         <body>
  29.             {$user_name}您好,欢迎你注册本站用户!
  30.         </body>
  31.         </html>
  32.         EOT;

  33.         $mail->AltBody="text/html";
  34.         if($mail-Send()){    
  35.             info_write("ok.txt","$user_name发送成功");
  36.         }else{
  37.             info_write("falied.txt","$user_name发送失败,错误信息$mail->ErrorInfo");
  38.         }

  39.     }

  40.     function info_write($filename,$info_log){
  41.         $info.= $info_log;
  42.         $info.="\r\n";
  43.         $fp = fopen($filename,a);
  44.         fwrite($fp,$info);
  45.         fclose($fp);
  46.     }
  47. //定时跳转到页面函数,1000是1秒,可自定义
  48.     function redirect($url){
  49.         echo "