Note that there are some explanatory texts on larger screens.

plurals
  1. POWarning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25
    primarykey
    data
    text
    <p>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 error:</p> <blockquote> <p>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()</p> </blockquote> <p>How do I go about resolving this?</p> <p>here is the code I have so far:</p> <pre><code>&lt;?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 "&lt;span class='form2'&gt;We're sorry, but we could not find a user with that email address.&lt;p&gt;Please try again.&lt;p&gt; &lt;a href='forgotpassword.php' class='form'&gt;Return&lt;/a&gt;&lt;/span&gt;"; } else { // create a random password function createRandomPassword() { $chars = "abcdefghijkmnopqrstuvwxyz023456789"; srand((double)microtime()*1000000); $i = 0; $pass = '' ; while ($i &lt;= 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:noreply@domain.com"); // display message echo "&lt;span class='form2'&gt;Thanks. Your new password has been sent to &lt;i&gt;".$row_email['email']."&lt;/i&gt;.&lt;p&gt; &lt;a href='index.php' class='form'&gt;Return&lt;/a&gt;&lt;/span&gt;"; } exit; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload