proud Posted February 21, 2007 Share Posted February 21, 2007 This script is supposed to submit an email to a user who forgot his password, but i dont know whats wrong with the script although i tried my best i keep getting this error . Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\AppServ\www\forgotpassck.php on line 44. By the way if this script wont work does anyone know an alternative? note:I added a comment in Line 44. <? include "connect.php"; ?> <html> <head> <title>Forgot Pass CK</title> </head> <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000"> <? $email=mysql_real_escape_string($email); $status = "OK"; //error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR); if (!stristr($email,"@") OR !stristr($email,".")) { $msg="Your email address is not correct<BR>"; $status= "NOTOK";} if($status=="OK"){ $query="SELECT * FROM users WHERE users.user_email = '$email'"; $st=mysql_query($query); $recs=mysql_num_rows($st); $row=mysql_fetch_object($st); $em=$row->user_email;// email is stored to a variable if ($recs == 0) { echo "<center><font face='Verdana' size='2' color=red><b>No Password</b><br> Sorry Your address is not there in our database . You can signup and login to use our site. <BR><BR><a href='login.php'> Login</a> </center>"; exit;} $headers4="yassirca@hotmail.com"; ///// Change this address within quotes to your address /// $headers.="Reply-to: $headers4\n"; $headers .= "From: $headers4\n"; $headers .= "Errors-to: $headers4\n"; //$headers = "Content-Type: text/html; charset=iso-8859-1\n".$headers;// for html mail un-comment this line //////// line44 //////// if(mail("$em","Your Request for login details","This is in response to your request for login detailst at site_name \n \nLogin ID: $row->user_id \n Password: $row->user_pass \n\n Thank You \n \n siteadmin","$headers")){echo "<center><font face='Verdana' size='2' ><b>THANK YOU</b> <br>Your password is posted to your email address . Please check your mail after some time. </center>";} else{ echo " <center><font face='Verdana' size='2' color=red >There is some system problem in sending login details to your address. Please contact site-admin. <br><br><input type='button' value='Retry' onClick='history.go(-1)'></center></font>";} } else {echo "<center><font face='Verdana' size='2' color=red >Your email address is not correct <br><br><input type='button' value='Retry' onClick='history.go(-1)'></center></font>";} ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
tom100 Posted February 21, 2007 Share Posted February 21, 2007 Your mail settings are setup wrong, or you don't have anything setup. Your script is fine, but your server can't send mail. http://www.php.net/manual/en/ref.mail.php Quote Link to comment Share on other sites More sharing options...
skali Posted February 21, 2007 Share Posted February 21, 2007 It seems that you are trying your script on your local machine and it does not have a SMTP server configured. Which is required to send mails. You can use some external SMTP server if you have access to any. You can define the details of your SMTP server in your php.ini file and that will allow emails to be sent. You can also configure SMTP server on your local machine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.