【问题标题】:PHP Mail $to multiple recipients from database tablePHP Mail $到数据库表中的多个收件人
【发布时间】:2009-08-23 04:35:57
【问题描述】:
<?php include("admin/db.php"); 
$recipients = "SELECT * FROM recipients ORDER BY id DESC";
$email_list = $db->query($recipients);
foreach($email_list as $row) {
    echo $row['email'].","; 
}

$to = "?";

?>

上面我有一个逗号分隔的电子邮件列表,我需要将其插入到 $to 变量中。我该怎么做?

【问题讨论】:

    标签: php email-address


    【解决方案1】:
    $recipients = "SELECT * FROM recipients ORDER BY id DESC";
    while ($row = mysql_fetch_array($recipients))
    {
        $adresses[] = $row['email']; 
    }
    
    $to = implode(",",$adresses);
    

    【讨论】:

      【解决方案2】:
      foreach($email_list as $row) {
          echo $row['email'].","; 
      
      
        mail($row['mail'], $subject, $body)
      
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-09-29
        • 2016-09-30
        • 2020-03-30
        • 2017-08-27
        • 1970-01-01
        • 2012-02-19
        • 2011-11-15
        • 2011-03-18
        相关资源
        最近更新 更多