I am trying to send the forgotten password to the mail address captured. The code is as follows. I am getting the message Your password has been sent to the mail id. Also correct password is selected from the database. But I am not receiving the message. I hava a contact us form in my site. It is working fine. I can not fix this... Any help... //Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); // value sent from form $email_to=$_POST['email']; // table name $tbl_name="tb_signup"; // retrieve password from table where e-mail = $email_to $sql="SELECT password FROM $tbl_name WHERE email='$email_to'"; $result=mysql_query($sql); // if found this e-mail address, row must be 1 row // keep value in variable name "$count" $count=mysql_num_rows($result); // compare if $count =1 row if($count==1){ $rows=mysql_fetch_array($result); // keep password in $your_password $your_password=$rows['password']; echo $your_password; // ---------------- SEND MAIL FORM ---------------- // send e-mail to ... $to=$email_to; // Your subject $subject="Your password here"; // From $visitormail="reachme@worth2read.org"; $from = "From: $visitormail\r\n"; echo $from; // 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,$from); echo $sentmail; } // else if $count not equal 1 else { echo "Not found your email in our database"; } // if your email succesfully sent if($sentmail){ echo "Your Password Has Been Sent To Your Email Address."; } else { echo "Cannot send password to your e-mail address"; } ?>
check the junk mail or spam folder of "reachme@worth2read.org". Are you sure function mail() is not producin ga warning or error. And does script show final message "Your Password Has Been Sent To Your Email Address." ? regards
is the from address. I am sending mail to the mail id in the database/ or the mail id user enters. the circumstance is the visitor forgot password and I am sending it to the visitor's id. Since I put the echo statements in the code, I am getting password correctly. Also the our Password Has Been Sent To Your Email Address' message is coming. The value of sentmail is shown as 1 also...I checked the spam folders. It has not come...
Could you use [^php^]CODE HERE[/^PHP^] *remove ^* It's really hard to read the code without a wrapper =/ At the top of everyone *around in <?php* put error_reporting('E_ALL'); also, when grabbing the sql row, echo $to_email to see if its pasting.
I tried error_reporting('E_ALL'); No error came... $to_email is printing correctly. The code is at www.worth2read.org/test/forgot.php http://www.worth2read.org/test/signup.php-----can sign up I am not getting the mail...
the mail function by default uses the mail transfer agent sendmail to send all mails. In some linux box I think sendmail are not configured properly. Why don't you use phpmailer, simple and clean to use, object oriented. I'll highly recommend it : http://phpmailer.codeworxtech.com/
I tried error_reporting('E_ALL'); No error came... ... That turns off error reporting! The line you want is: error_reporting(E_ALL);
Ahh d'oh forgot they are without quotes, ah well Maybe gezzle is right (about sendmail *or postfix or qmail* being misconfigured, or there is something in the source we haven't seen, as you are pasting just the part of what it should do, but not the forms used and how it manages $_POST. Heck it might even be a little <form> problem perhaps Also you might want to rethink the way you are storing passwords... just storing them plain raw.. well just my 2 cents on that part.
I appreciate ur comments. I tried everything. All the echo stmts r working...Getting the message mail is send. But I am not getting mail. Now I noticed that among server information it is written as Path to send mail : /usr/sbin/sendmail Does it have something to do with the code...
Hi The following simple code also is not working... <?php error_reporting(E_ALL); $to="admin@yahoo.com.sg"; $subject="message"; $messages= "Your password is \r\n"; $mailheader = 'From: "admin" <reachme@worth2read.org>' . "\r\n" . 'Reply-To: ' . "\r\n" . 'x-mailer: php/' . phpversion() . "\r\n"; if( mail( $to,$subject,$messages,$mailheader)) { echo "We've sent the mail.\n"; } else { echo "Could not send mail. Please try again later\n"; } ?>
I think it is the problem with email configuration. I can send mail to the mail ids in my domain, ie I can send mail to . To other mail ids(Yahoo, Gmail etc) I can't send... Any ideas..
Do you use shared hosting? Sometimes email from shared hosting just got deleted/blocked without notices (not even put in the SPAM box). My suggestion: If the mail you send using your hosting webmail from reach Yahoo, Gmail, etc. Find out what is your email SMTP settings, then try to use email SMTP library (like Swift Mailer http://swiftmailer.org/ to send the email trough your SMTP directly, bypassing the sendmail).