/**
- * Bulk Mail sample
- * Phpmailer Class Application Example
- */
- Phpmailer class file
- Require_once ("class.phpmailer.php");
Send email 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: Normal mail authentication does not need to add @ domain name
- $mail->password = "1983106"; SMTP Password
$mail->from = ""; Sender Mailbox
- $mail->fromname = "WWW.JBXUE.COM"; The sender, such as the programmer's home.
$mail->charset = "GB2312"; Specify the character set here!
- $mail->encoding = "base64";
$mail->addaddress ($sendto _email, $user _name); Recipient's mailbox and name
- $mail->addreplyto ("", "home of the programmer");
$mail->wordwrap = 50; Set word Wrap
- $mail->addattachment ("/var/tmp/file.tar.gz"); Attachment Accessories 1
- $mail->addattachment ("/tmp/image.jpg", "new.jpg"); Annex 2
- $mail->ishtml (TRUE); Send As HTML
- $mail->subject = $subject;
Message content can be sent directly to HTML file
- $mail->body = <<<>
- Phpmailer Bulk Mail Sample _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 failure, error message $mail->errorinfo");
- }
- }
- Send Email function end
Write send result function, error log record
- function Info_write ($filename, $info _log)
- {
- $info. = $info _log;
- $info. = "\ r \ n";
- $fp = fopen ($filename, a);
- Fwrite ($fp, $info);
- Fclose ($FP);
- }
Timed jump page function where 1000 is the time, 1 seconds, you can customize
- function redirect ($url)
- {
- echo "";
- }
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, message subject, message content, additional information, user name)
- $i = $_get[' action '];
- $i + +;
- if ($i < $len)
- {
- $rs =explode ("@", $list _email[$i]);
- $user _name = $rs [' 0 '];
- echo "Sending {$i} ({$list _email[$i]}) Mail ... {$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 messages sent";
- Exit
- }
- ?>
Copy CodeCode Description: Read the above article Email.txt, can also be directly QQ number, each line a number, and then use Fget () read each line QQ number, finally add QQ mailbox suffix @qq. com. This clever idea, hoping to help you, huh. Attached, Phpmailer Mail Send class V5.1 download address. |