I have this form that is working perfectly except that it won't send emails to multiple people. It only sends it to one person. How do i fix this? I want to be able to send each individual a individual email with their email address in the to field regardless if that same email was sent to other users.
Update: I did a print $email; and if i select only one email it would print it and then if i more than 1 then it wouldn't print anything. So that means its not detecting more than 1 email.
$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
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1
";
$headers .= "From: $usermail
";
$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 "";
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…