循环邮件阅读MySQL

Posted

tags:

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

  1. <?php
  2. set_time_limit(0);// this will keep the script from stopping if it takes longer then 30 seconds, must have this here
  3. mysql_connect("localhost", "root", "pass");
  4. mysql_select_db("database");
  5. $query = mysql_query("SELECT email FROM account");
  6. $emailsubject = "This is a sample subject!";
  7. $emailbody = file_get_contents("email.html");
  8. $fromaddress = "[email protected]";
  9.  
  10.  
  11. // here we loop through the mysql array until we reach then end
  12. while ($row = mysql_fetch_array($query, MYSQL_NUM))
  13. {// start while
  14.  
  15. // we use the sql var. $row and we use the field 0 to pickup the email address
  16. mail($row[0], $emailsubject, $emailbody, "From: " . $fromaddress . " X-Mailer: PHP 4.x");
  17.  
  18. }// end while
  19.  
  20. ?>

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

PHP 循环电子邮件阅读平面文件

用于阅读电子邮件的 PHP 库

Laravel 邮件队列无限循环异常

邮件循环回我自己

在循环中使用 php mail() 函数发送 +-200 封电子邮件

存储过程之流程控制语句