循环电子邮件读取平面文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了循环电子邮件读取平面文件相关的知识,希望对你有一定的参考价值。

  1. <?php
  2.  
  3. set_time_limit(0); // this will keep the script from stopping if it takes longer then 30 seconds, must have this here
  4. $emailaddress = file("email-list.txt"); // load from a flat file, assuming 1 email per line in the file
  5. $emailsubject = "This is a sample subject!";
  6. $emailbody = file_get_contents("email.html");
  7. $fromaddress = "[email protected]";
  8. $i = count($emailaddress);
  9. $z = 0;
  10.  
  11. // here we check how many email address's we have, if its is 0, then we don't start the email function
  12. if ($i != 0)
  13. {// start if
  14.  
  15. // Lets loop until we reach the count from email address arrar
  16. while ($i != $z)
  17. {// start while
  18.  
  19. // here we send the email to the varables from above, using the email array incrament
  20. mail($emailaddress[$z], $emailsubject, $emailbody, "From: " .$fromaddress. " X-Mailer: PHP 4.x");
  21.  
  22. // lets echo out that the email was sent
  23. echo $z + 1 . " out of " . $i . " emails sent. (" . $emailaddress[$z] . ")<br>";
  24.  
  25. // increment the array one, so we get a new email address from the array
  26. ++$z;
  27.  
  28. }// end while
  29.  
  30. }//end if
  31.  
  32. else
  33. {//start else
  34.  
  35. // we echo out that no emails where found in the array and end the script
  36. echo "Warning: No emails in array.";
  37.  
  38. }// end else
  39.  
  40. ?>

以上是关于循环电子邮件读取平面文件的主要内容,如果未能解决你的问题,请参考以下文章

PHP 循环电子邮件读取数组

循环电子邮件读取数组

自动化 Excel 工作 - 将平面文件转换为 Excel 电子表格

C# Po3协议读取邮件内容遇到的问题

读取电子邮件的文本文件转换为 Javamail MimeMessage

Excel VBA - 循环遍历多个文件夹中的文件,复制范围,粘贴到此工作簿中