tags:

views:

309

answers:

3

i've been trying to set up a forgot password facility on a website which i am building but each time i try to load the page i am greeted by the above error. how do i go about resolving this?

here is the code i have so far...

<?php

            if (array_key_exists('forgot',$_POST)) {

      $email = $_POST['email']; 

      mysql_select_db($database_speedycms, $speedycms);
      $query_email = "SELECT * FROM tbl_users WHERE email='$email'";
      $email = mysql_query($query_email, $speedycms) or die(mysql_error());
      $row_email = mysql_fetch_assoc($email);
      $totalRows_user = mysql_num_rows($email);

      mysql_query("SELECT * FROM users WHERE email='$email'");

      if($totalRows_user == 0)

      {
      echo "<span class='form2'>We're sorry, but we could not find a user with that email address.<p>Please try again.<p>
      <a href='forgotpassword.php' class='form'>Return</a></span>";
      }

      else

      {


        // create a random password 
      function createRandomPassword() { 
      $chars = "abcdefghijkmnopqrstuvwxyz023456789"; 
         srand((double)microtime()*1000000); 
         $i = 0; 
         $pass = '' ; 
      while ($i <= 7) { 
            $num = rand() % 33; 
            $tmp = substr($chars, $num, 1); 
            $pass = $pass . $tmp; 
            $i++; 
          } 
         return $pass; 
      }
      $password = createRandomPassword(); 


      // generate email

      $username = $row_email['username'];
      $msg  = "Your new login information is:\n\n";
      $msg .= "Username: $username\n";
      $msg .= "Password: $password\n";

      mail("$email", "Speedy CMS Login Information", "$msg", "From:[email protected]");

      // display message  

      echo "<span class='form2'>Thanks. Your new password has been sent to <i>".$row_email['email']."</i>.<p>
      <a href='index.php' class='form'>Return</a></span>";

      }

      exit;

      }

    ?>

any help would be appreciated! thanks!

+1  A: 

Looks like your server doesn't have a smtp mailserver running. You could use these functions to set a different smtp server:

ini_set('SMTP', "server.com");
ini_set('smtp_port', "25");
ini_set('sendmail_from', "[email protected]");

Of course you must know an active smtp server.

Good luck!

Bas
any ideas which smtp server i could use?
jeansymolanza
Maybe you could use your isp's mail server. Some don't require to login.
Bas
A: 

It looks like you do not have a SMTP server running on the system your website is running. What kind a server is it?

Stegeman
i'm using xampp for local development
jeansymolanza
Ok, try to get it running on a server which also has an SMTP service running. Or configure your PHP to use an external mail server.
Stegeman
can you recommend any free external mail servers?
jeansymolanza
There is no such thing as free external mail servers (at least reliable ones)... Imagine the SPAM abuse these server would have!
AlexV
A: 

Looks like you are using a local PHP installation (using WAMPSERVER, EasyPHP or else) because "real" hosts rarely misconfig their server. If it's the case, edit the php.ini and use your ISP settings example:

[mail function]
SMTP = mail.yourdomain.com
smtp_port = 25
AlexV
can i use google mail's smtp server?
jeansymolanza
I'm not sure of the Google rules to use their SMTP server. I'm pretty sure you must be authenticated to use their SMTP server and I don't see this kind of setting in PHP.ini... But you can use your ISP settings with this for sure.
AlexV