Hey everyone, i've got a little problem with the mail() function.
So to clarify i'm unluckily running php with IIS and mssql. I'm trying to do send mail to someone if they forgot their password, however when I send mail it always fails. Here is the part of my phpinfo() page, the smtp server is set up correctly because it mails in asp just fine.
sendmail_from no value no value
sendmail_path no value no value
also my code
<?php
require_once('connectdb.php');
$tnum = $_POST['tnum'];
$qry = mssql_query("SELECT passwd, email FROM members WHERE
TNumber='$tnum'");
$result = mssql_num_rows($qry);
if($result == 1)
{
$rows=mssql_fetch_array($qry);
// keep password in $your_password
$your_password=$rows['passwd'];
// ---------------- SEND MAIL FORM ----------------
// send e-mail to ...
$to=$rows['email'];
// Your subject
$subject="Forgotten Password";
// From
$header="From: $to";
// Your message
$messages= "Your password for login to our website \r\n";
$messages.="Your password is $your_password \r\n";
$messages.="more message... \r\n";
// send email
$sentmail = mail($to,$subject,$messages,$header);
}
// else if $count not equal 1
else {
echo "Could not find your email in our database<Br> ";
}
// if your email succesfully sent
if($sentmail){
echo "Your Password Has Been Sent To Your Email Address.";
echo "<a href=login-form.php>Login Page</a>";
}
else {
echo "Cannot send password to your e-mail address<br>";
echo $to;
}
?>