我正在从记录集中提取电子邮件。他们循环并正确回显,但只发送到最后一条记录?我在这里想念什么?似乎它也回显了它应该发送的电子邮件。谢谢
$query_email = "SELECT email FROM UserInfo";
$email = mysql_query($query_email, $dandee123) or die(mysql_error());
$numRows = mysql_num_rows($email);
for ($count = 0; $count < $numRows; $count++){
$row[] = mysql_fetch_array($email, MYSQL_ASSOC);
}
$subject = strip_tags($_POST['subject']);
$headers = "From: contact@xxxx\r\n";
$headers .= "Reply-To: contact@xxx";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= $_POST['messagesent'];
$message .= '</body></html>';
foreach ($row as $email)
{
$to = $email['email'];
mail($to, $subject, $message, $headers);
//this works below but email only goes to last record?
print "sent to ". $to;
}