PHP Mail $从数据库表发送给多个收件人

发布于 2024-08-03 11:31:22 字数 292 浏览 3 评论 0原文

<?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 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 = "?";

?>

Above I have a comma delimitated list of emails which I need to insert into the $to variable. How do I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦忆晨望 2024-08-10 11:31:22
$recipients = "SELECT * FROM recipients ORDER BY id DESC";
while ($row = mysql_fetch_array($recipients))
{
    $adresses[] = $row['email']; 
}

$to = implode(",",$adresses);
$recipients = "SELECT * FROM recipients ORDER BY id DESC";
while ($row = mysql_fetch_array($recipients))
{
    $adresses[] = $row['email']; 
}

$to = implode(",",$adresses);
给不了的爱 2024-08-10 11:31:22
foreach($email_list as $row) {
    echo $row['email'].","; 


  mail($row['mail'], $subject, $body)

}
foreach($email_list as $row) {
    echo $row['email'].","; 


  mail($row['mail'], $subject, $body)

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文