Skip to main content
Inspiring
Mar 16, 2012 1:53 PM UTC
Question

Forgot password mailer not working

Can any one see wha't worng here.

This piece of code should return the users password by email but the email arrives successfully without any password.

The email is sucessfully passed as $_POST['email'] as it is used as the email address for the email sent so something else msut be wrong>

Any ideas?

***********************************

$email = $_POST['email'] ;

 

$sql = mysql_query("SELECT email, password FROM users where email = '$email'")

or die(mysql_error()); 

$row = mysql_fetch_array($sql);

$rownum = mysql_num_rows($sql);

$to= $row['email'];

$subject= "Your login details";

if(!$rownum  ) {

echo "<H3>Sorry, that email address does not match our records</H3>";

}

if($rownum ==1  ){

$message   .= "Your password is:\n\n".$row['password']."\n\n

 

To sign-in click here http://www.mysite.com/admin/sign-in.php";

     

$header = "From: support@mysite.com.com";    

    

$sent =  mail($to,$subject,$message,$header);

if($sent)

{

print "<H3>Your password has been sent to your e mail address</H3>" ;

}

}

***********************************

This topic is closed to new replies. Start a new post to keep the conversation going.

3 replies

Mar 21, 2012 7:49 AM UTC

Are you seeing "Your password has been sent to your e mail address" message?

It can be a lot of things.

Some servers (recipient side) will accept emails with proper headers only.

You are sending the email as user "nobody". Your server might be set to prevent to send emails as nobody which requires you to send it via SMTP connection.(you can ask your host about this)

Translate
Participating Frequently
Mar 21, 2012 5:11 PM UTC

Burak, the OP mentioned that the email arrives, but the content is not as expected. So it sounds like something malformed in the $message string.

Translate
Participating Frequently
Mar 16, 2012 5:59 PM UTC

Show us what the contents of the email actually look like.

>$message   .= "Your password is:\n\n".$row['password']."\n\n

Looks like you're missing the closing double quote.

Translate