-
-
/** - * Bulk email example
- * phpmailer application example
- */
- //PHPmailer class file
- require_once("class.phpmailer.php");
function smtp_mail ($sendto_email, $subject, $body, $extra_hdrs, $user_name) { - $mail = new PHPMailer();
- $mail->IsSMTP(); // send via SMTP
- $mail->Host = "smtp.163.com"; // SMTP servers
- $mail->SMTPAuth = true; // turn on SMTP authentication
- $mail->Username = "test123"; // SMTP username Note: Ordinary email authentication does not require adding @domain name
- $mail->Password = "1983106"; // SMTP password
$mail->From = ""; // Send Sender's email address
- $mail->FromName = "WWW.JBXUE.COM"; // Sender, such as Programmer's Home
$mail->CharSet = "GB2312" ; //Specify the character set here!
- $mail->Encoding = "base64";
$mail->AddAddress($sendto_email,$user_name); // Recipient email and name
- $mail-> AddReplyTo("","Programmer's Home");
//$mail->WordWrap = 50; // set word wrap
- //$mail->AddAttachment(" /var/tmp/file.tar.gz"); // attachment attachment 1
- //$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment 2
- $ mail->IsHTML(true); // send as HTML
- $mail->Subject = $subject;
// The email content can be sent directly as html file
- $mail-> Body = <<
- phpmailer mass email example_bbs.it-home.org
- < /body>
- EOT;
- $mail->AltBody ="text/html";
- if($mail->Send())
- {
- info_write("ok.txt"," $user_name was sent successfully");
- }
- else {
- info_write("falied.txt","$user_name failed, error message $mail->ErrorInfo");
- }
- }
- //End of sending Email function< /p>
// Write the send result function, error log record
- function info_write($filename,$info_log)
- {
- $info.= $info_log;
- $info.="rn";
- $ fp = fopen ($filename,a);
- fwrite($fp,$info);
- fclose($fp);
- }
//Timed jump page function where 1000 is the time ,1 second, you can customize
- function redirect($url)
- {
- echo "<script></li>
<li>function redirect()</li>
<li>{</li>
<li>window.location.replace('$url');</li>
<li>}</li>
<li>window.setTimeout ('redirect();', 15000);</li>
<li></script>";
- }
//Read text email address You can also read the database
- $filename = "email. txt";
- $fp = fopen($filename,"r");
- $contents = fread($fp,filesize($filename));
- $list_email=explode("rn",$contents);
- $len =count($list_email);
- fclose($fp);
// Parameter description (send to, email subject, email content, additional information, user name)
- $i = $_GET ['action'];
- $i++;
- if ($i<$len)
- {
- $rs=explode("@",$list_email[$i]);
- $user_name = $rs['0'] ;
- echo "Sending the {$i}th ({$list_email[$i]}) email...{$user_name}";
- smtp_mail($list_email[$i], 'Treasurery Online Weekly No. Issue 12', $body, 'http://bbs.it-home.org/', $user_name);
- redirect("?action=$i");
- }
- else {
- echo "Send all emails Completed";
- exit;
- }
- ?>
-
-
Copy code
Code description:
The above method of reading the article email.txt can also directly read the QQ number, one number per line, and then use fget() to read the QQ number in each line, and finally add the QQ mailbox suffix @qq.com.
This smart idea, I hope it will be helpful to you.
Attached is the download address of PHPMailer email sending class V5.1.
|