PHP 邮件:多个收件人? [英] PHP mail: Multiple recipients?

查看:38
本文介绍了PHP 邮件:多个收件人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码:

<?php
include("db.php");

$result = mysql_query("SELECT * FROM email");

while($row = mysql_fetch_array($result))
{
$to = $row['address'];
}
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "example@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
?>

在我的表(电子邮件")中,我有多个地址.(它们不是逗号分隔的.)我如何将我的消息发送到所有这些地址?

In my table ("email") I have multiple addresses. (They are not comma sepparated.) How could I send my message to all of those addresses?

推荐答案

while($row = mysql_fetch_array($result))
{
    $addresses[] = $row['address'];
}
$to = implode(", ", $addresses);

mail() 手册页所述,函数的to"参数可以采用逗号分隔的地址列表.

As specified on the mail() manual page, the "to" parameter of the function can take a comma-separated list of addresses.

这篇关于PHP 邮件:多个收件人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆