/**
- * Example of mass mailing
- * Phpmailer application instance
- */
- // PHPmailer class file
- Require_once ("class. phpmailer. php ");
// Email sending function
- 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: @ domain name is not required for normal mail authentication.
- $ Mail-& gt; Password = "1983106"; // SMTP password
$ Mail-> From = ""; // sender's email
- $ Mail-> FromName = "WWW. JBXUE. COM"; // sender, such as programmer's house
$ Mail-> CharSet = "GB2312"; // The character set is specified here!
- $ Mail-> Encoding = "base64 ";
$ Mail-> AddAddress ($ sendto_email, $ user_name); // recipient's email address and name
- $ Mail-> AddReplyTo ("", "Programmer's House ");
// $ Mail-> WordWrap = 50; // set word wrap
- // $ Mail-> AddAttachment ("/var/tmp/file.tar.gz"); // 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 directly sent to html files
- $ Mail-> Body = <
- Phpmailer mail group example _ bbs.it-home.org
-
- EOT;
- $ Mail-> AltBody = "text/html ";
- If ($ mail-> Send ())
- {
- Info_write ("OK .txt", "$ user_name sent successfully ");
- }
- Else {
- Info_write ("falied.txt", "$ user_name failed, error message $ mail-> ErrorInfo ");
- }
- }
- // The Email sending function ends.
// Write the sending result function, error log record
- Function info_write ($ filename, $ info_log)
- {
- $ Info. = $ info_log;
- $ Info. = "\ r \ n ";
- $ Fp = fopen ($ filename, );
- Fwrite ($ fp, $ info );
- Fclose ($ fp );
- }
// Scheduled page jump function, where 1000 is the time, 1 second, you can customize
- Function redirect ($ url)
- {
- Echo "script"
- Function redirect ()
- {
- Window. location. replace ('$ URL ');
- }
- Window. setTimeout ('Redirect (); ', 15000 );
- Script ";
- }
// Read the text email address. you can also read the database.
- $ Filename = "email.txt ";
- $ Fp = fopen ($ filename, "r ");
- $ Contents = fread ($ fp, filesize ($ filename ));
- $ List_email = explode ("\ r \ n", $ contents );
- $ Len = count ($ list_email );
- Fclose ($ fp );
// Parameter description (sent to, subject, 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} ({$ list_email [$ I]}) email... {$ user_name }";
- Smtp_mail ($ list_email [$ I], 'treasurery Online weekly 12th ', $ body, 'http: // bbs.it-home.org/', $ user_name );
- Redirect ("? Action = $ I ");
- }
- Else {
- Echo "all emails have been sent ";
- Exit;
- }
- ?>
-
Code description. This smart idea is helpful to you. Appendix, PHPMailer mail sending class V5.1. |