开发者

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25

开发者 https://www.devze.com 2022-12-21 18:29 出处:网络
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:

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:

Warning: mail() [function.ma开发者_如何学Goil]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

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:noreply@domain.com");

      // 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;

      }

    ?>


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@domain.com");

Of course you must know an active smtp server.

Good luck!


You have to configure these values on php.ini file

SMTP = smtp.yourdomain.com  
smtp_port = 25 
username = info@yourdomain.com
password = yourmailpassord
sendmail_from = info@yourdomain.com

You can provide same details as in outlook config. Some servers are checking "sendmail_from" adress also.


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


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


Warning: mail(): SMTP server response: 550 Access denied - Invalid HELO name (See 
RFC2821 4.1.1.1) in C:\AppServ\www\VOGUE\email.php on line 38

after add following codes...............

ini_set('SMTP', "server.com");

ini_set('smtp_port', "25");

ini_set('sendmail_from', "email@domain.com");

how to add password of "sendmail_from" account???????
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号