mail function not working

[php]while($row = mysql_fetch_array($sql))
{
$id = $row[“id”];
$un = $row[‘username’];
$to = “$email”;
// Change this to your site admin email
$subject = “Password Reset”;
//Begin HTML Email Message where you need to change the activation URL inside
$message = ‘

Hi $un

Someone has requested a password reset for your account. If this was you, CLICK HERE. Otherwise just delete this email and report it to me. I will have a report form soon.



NOTE: Do NOT reply to this E-Mail, the account is not monitored.

’;
// end of message
$headers = ‘From: [email protected]\r\nContent-type: text/html\r\n’;
// Finally send the activation email to the member
if (mail($to, $subject, $message, $headers))
{
exit(“You should have your reset within a couple minutes.”);
}
else
{
exit(“Failed to send reset, try again later.”);
}
}[/php]

It came back with Failed to send reset, try again later.

What am I doing wrong?

most likely because $to = “$email”; is wrong. To php, that’s a literal string, meaning it doesn’t see $email as a variable, but as a string. Just take the quotes off and it should work. Also, you don’t need a loop to process that query. Just use mysql_fetch_assoc() instead of array.

Sponsor our Newsletter | Privacy Policy | Terms of Service