我有这个工作完美的表格,除了它不会向多个人发送电子邮件。它只发送给一个人。我该如何解决?我希望能够向每个人发送一封单独的电子邮件,他们的电子邮件地址位于收件人字段中,无论同一电子邮件是否发送给其他用户。
更新:我做了一个 print $email; 如果我只选择一封电子邮件,它会打印它,然后如果我超过 1 则它不会打印任何东西。这意味着它不会检测到超过 1 封电子邮件。
$sql = "SELECT email from
friend_email_ids WHERE my_id='$id'";
$result = mysql_query($sql);
$query = mysql_query($sql) or die ("Error: ".mysql_error());
if ($result == "")
{
echo "";
}
echo "";
$rows = mysql_num_rows($result);
$emails = array();
if($rows == 0)
{
print("");
}
elseif($rows > 0)
{
while($row = mysql_fetch_array($query))
{
array_push($emails, $row['email']);
print("");
}
}
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "From: $usermail\r\n";
$subject = "$full_name added";
$message = "<html><body>";
$message .= "Hello, <br><br>$full_name posted someth<br><br>";
$message .= "<a href=www.domain.com/signup.php?t=&sign=>Click here.</a><br><br>";
$message .= "</body></html>";
foreach ($emails as $email) {
mail($email, "Subject: $subject", $message, $headers);
}
echo "";