Hi!
I am new to this website.
I am trying to use a "forgot password script" that i downloaded from a website (ive tryed others, but they dont work either). wen u press on the "send" button, it is supposed to generate a new password and send it to the users email. but instead, i am getting theese error messages:
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
xx\xxx\xxx\xxx\include\mailer.php on line
63
Warning: Cannot modify header information - headers already sent by (output started at xx\xxx\xxx\xxx\include\mailer.php:63) in
xx\xxx\xxx\xxx\process.php on line
170
This is my "Process.php"
Code:
/**
* procForgotPass - Validates the given username then if
* everything is fine, a new password is generated and
* emailed to the address the user gave on sign up.
*/
function procForgotPass(){
global $database, $session, $mailer, $form;
/* Username error checking */
$subuser = $_POST['user'];
$field = "user"; //Use field name for username
if(!$subuser || strlen($subuser = trim($subuser)) == 0){
$form->setError($field, "* Username not entered<br>");
}
else{
/* Make sure username is in database */
$subuser = stripslashes($subuser);
if(strlen($subuser) < 5 || strlen($subuser) > 30 ||
!eregi("^([0-9a-z])+$", $subuser) ||
(!$database->usernameTaken($subuser))){
$form->setError($field, "* Username does not exist<br>");
}
}
/* Errors exist, have user correct them */
if($form->num_errors > 0){
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->getErrorArray();
}
/* Generate new password and email it to user */
else{
/* Generate new password */
$newpass = $session->generateRandStr(8);
/* Get email of user */
$usrinf = $database->getUserInfo($subuser);
$email = $usrinf['email'];
/* Attempt to send the email with new password */
if($mailer->sendNewPass($subuser,$email,$newpass)){
/* Email sent, update database */
$database->updateUserField($subuser, "password", md5($newpass));
$_SESSION['forgotpass'] = true;
}
/* Email failure, do not change password */
else{
$_SESSION['forgotpass'] = false;
}
}
header("Location: ".$session->referrer);
}
And this is my "Mailer.php":
Code:
<?
/**
* Mailer.php
*
* The Mailer class is meant to simplify the task of sending
* emails to users. Note: this email system will not work
* if your server is not setup to send mail.
*
* If you are running Windows and want a mail server, check
* out this website to see a list of freeware programs:
* <Freeware downloads Server Tools - Mail Server Tools at SnapFiles.com>
*
* Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
* Last Updated: August 19, 2004
*/
class Mailer
{
/**
* sendWelcome - Sends a welcome message to the newly
* registered user, also supplying the username and
* password.
*/
function sendWelcome($user, $email, $pass){
$from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
$subject = "Feelay's Site - Welcome!";
$body = $user.",\n\n"
."Welcome! You've just registered at Feelay's Site "
."with the following information:\n\n"
."Username: ".$user."\n"
."Password: ".$pass."\n\n"
."If you ever lose or forget your password, a new "
."password will be generated for you and sent to this "
."email address, if you would like to change your "
."email address you can do so by going to the "
."My Account page after signing in.\n\n"
."- Feelay";
return mail($email,$subject,$body,$from);
}
/**
* sendNewPass - Sends the newly generated password
* to the user's email address that was specified at
* sign-up.
*/
function sendNewPass($user, $email, $pass){
$from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
$subject = "Feelay's Site - Your new password";
$body = $user.",\n\n"
."We've generated a new password for you at your "
."request, you can use this new password with your "
."username to log in to Feelay's Site.\n\n"
."Username: ".$user."\n"
."New Password: ".$pass."\n\n"
."It is recommended that you change your password "
."to something that is easier to remember, which "
."can be done by going to the My Account page "
."after signing in.\n\n"
."- Feelay";
return mail($email,$subject,$body,$from);
}
};
Thanks for any Replie
//Feelay