PHP program for bulk Mail by reading text

Source: Internet
Author: User
Tags word wrap
  1. Request Phpmailer class file

  2. Require_once ("class.phpmailer.php");

  3. Send email function

  4. function Smtp_mail ($sendto _email, $subject, $body, $extra _hdrs, $user _name) {
  5. $mail = new Phpmailer ();
  6. $mail->issmtp (); Send via SMTP
  7. $mail->host = "smtp.163.com"; SMTP servers
  8. $mail->smtpauth = true; Turn on SMTP authentication
  9. $mail->username = "Jessiejl"; SMTP username Note: Normal mail authentication does not need to add @ domain name
  10. $mail->password = "1983106"; SMTP Password

  11. $mail->from = ""; Sender Mailbox

  12. $mail->fromname = bbs.it-home.org; Sender, Scripting Academy
  13. $mail->charset = "GB2312"; Specify the character set here!
  14. $mail->encoding = "base64";

  15. $mail->addaddress ($sendto _email, $user _name);//recipient mailbox and name

  16. $mail->addreplyto ("", "China Capital Management Network");

  17. $mail->wordwrap = 50; Set word Wrap

  18. $mail->addattachment ("/var/tmp/file.tar.gz");//Attachment Accessories 1
  19. $mail->addattachment ("/tmp/image.jpg", "new.jpg"); Annex 2
  20. $mail->ishtml (TRUE); Send As HTML
  21. $mail->subject = $subject;

  22. Message content can be sent directly to HTML file

  23. $mail->body = <<<>
  24. Treasurery Online Weekly
  25. EOT;
  26. $mail->altbody = "text/html";
  27. if ($mail->send ())
  28. {
  29. Info_write ("Ok.txt", "$user _name sent successfully");
  30. }
  31. else {
  32. Info_write ("Falied.txt", "$user _name failure, error message $mail->errorinfo");
  33. }
  34. }
  35. Send Email function end

  36. Write send result function, error log record

  37. function Info_write ($filename, $info _log)
  38. {
  39. $info. = $info _log;
  40. $info. = "\ r \ n";
  41. $fp = fopen ($filename, a);
  42. Fwrite ($fp, $info);
  43. Fclose ($FP);
  44. }

  45. Timed jump page function where 1000 is the time, 1 seconds, you can customize

  46. function redirect ($url)
  47. {
  48. echo "";
  49. }

  50. Read the text email address you can also read the database

  51. $filename = "Email.txt";
  52. $fp = fopen ($filename, "R");
  53. $contents = Fread ($fp, FileSize ($filename));
  54. $list _email=explode ("\ r \ n", $contents);
  55. $len =count ($list _email);
  56. Fclose ($FP);

  57. Parameter description (Sent to, message subject, message content, additional information, user name)

  58. $i = $_get[' action '];
  59. $i + +;
  60. if ($i < $len)
  61. {
  62. $rs =explode ("@", $list _email[$i]);
  63. $user _name = $rs [' 0 '];
  64. echo "Sending {$i} ({$list _email[$i]}) Mail ... {$user _name} ";
  65. Smtp_mail ($list _email[$i], ' treasurery Online weekly 12th ', $body, ' http://bbs.it-home.org/', $user _name);
  66. Redirect ("action= $i");
  67. }
  68. else {
  69. echo "All messages sent";
  70. Exit
  71. }
  72. ?>
Copy Code

Note: Read article Email.txt, can also be directly QQ number, each line a number, and then use Fget () read each line QQ number, Finally in addition QQ mailbox suffix @qq.com can, in fact, PHP bulk Mail is very simple, because the company needs PHP bulk Mail, so recently in a PHP bulk program system, you can freely set up a number of bulk mailbox, so that mass quantity there is guaranteed, all the settings are desktop, very intuitive operation! The above php bulk mail, a mass mailing number test between 100-200 and in the local mass can not upload online space!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.