PHP 循环电子邮件阅读MySQL

Posted

tags:

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

<?php
  set_time_limit(0);// this will keep the script from stopping if it takes longer then 30 seconds, must have this here
  mysql_connect("localhost", "root", "pass");
  mysql_select_db("database");
  $query = mysql_query("SELECT email FROM account");
  $emailsubject = "This is a sample subject!";
  $emailbody = file_get_contents("email.html");
  $fromaddress = "name@domain.tld";
  
  
  // here we loop through the mysql array until we reach then end
  while ($row = mysql_fetch_array($query, MYSQL_NUM))
  	{// start while
      
      // we use the sql var. $row and we use the field 0 to pickup the email address
      mail($row[0], $emailsubject, $emailbody, "From: " . $fromaddress . "\nX-Mailer: PHP 4.x");
	  
	}// end while

?>

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

循环邮件阅读MySQL

用于阅读电子邮件的 PHP 库

PHP中while循环和for循环的区别?

PHP 循环电子邮件读取数组

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

样式化 php 电子邮件以允许 Microsoft Outlook 阅读样式