Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    phpMailer problem

    phpMailer problem

    Hi all,

    This is part of the code I'm using to create a new password and I then wanted to email the new PW. This code was working fine a few weeks back but now I'm not getting the emails, I'm I doing something wrong. I did want to do do it using the "$email", but I carn't even get it to work using a full address - "c.dickinson40@ntlworld.com"

    Code:
    //New password
    function new_password($email){
       GLOBAL $db,$table;
       $email = trim($email);
       $query1 = mysql_query("SELECT userName from $table WHERE userMail = '$email'");
       if(mysql_num_rows($query1)<1){
          return "error=email not present into database";
       }
       $row = mysql_fetch_array($query1);
       $username=$row["userName"];
       $query = mysql_query("SELECT * FROM $table WHERE userName = '$username' AND userMail = '$email'");
       $rand_string = '';
       // ---
       // generating a random 8 chars lenght password
       // ---
       for($a=0;$a<7;$a++){
          do{
            $newrand = chr(rand(0,256));
          } while(!eregi("^[a-z0-9]$",$newrand));
          $rand_string .= $newrand;
       }
       $pwd_to_insert = md5($rand_string);
       $new_query = mysql_query("UPDATE $table SET userPassword = '$pwd_to_insert' WHERE userName = '$username' AND userMail = '$email'");
       //return "userName=$username&new_pass=$rand_string"; 
    	    require("phpmailer/class.phpmailer.php");
    			$mail = new PHPMailer();
    			$mail->IsSMTP(); // telling the class to use SMTP
    			$mail->Host = "stmp.ntlworld.com"; // SMTP server
    			$mail->SMTPAuth = true;
    			$mail->From = "coopersimon@postmaster.co.uk";
    			$mail->AddAddress("c.dickinson40@ntlworld.com");
    			$mail->Subject = "Login password";
    			$mail->Body = "\n\n\n\nYou requeted that a new password be sent to this email address\n\n"."User Name : ".$username."\n\nYour new password is : ".$rand_string."\n\n\n\nIf you have further problems please contact the moretype support staff.";
    			$mail->WordWrap = 50;
    			if(!$mail->Send()){
    			   echo "Message was not sent";
    			   echo "Mailer Error: " . $mail->ErrorInfo;
    			}else{
    			   echo "Message has been sent";
    			}
      }
    //"\n\n\n\n User Name : ".$username."\n\n Your new password is : ".$rand_string;
    ?>

  • #2
    Regular Coder
    Join Date
    Sep 2005
    Posts
    394
    Thanks
    1
    Thanked 0 Times in 0 Posts
    If the code was working fine, there's nothing wrong with it. It's likely a server config issue. Contact your host.

    ~Phil~


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •