循环电子邮件读取数组

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

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

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

遍历两个包含VBA中电子邮件的数组

labview写入一维数组到电子表格,如何做过第二次写入不覆盖第一次写入的数据

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

如何使用python从数组中删除特定元素

ThinkPHP模板循环输出Volist标签用法实例详解