SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Barbados
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with mailing script

    I've been trying to use the php mail() function and the PhpMailer opensource code but I can't figure out why it's not working. At best, I get an error message (specifically when using the mail() function) which is as follows:

    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 C:\Program Files\Apache Group\Apache2\htdocs\ServicesPortal\login_help.php on line 57

    I've checked php.ini and I believe I have to make changes to this section:
    [mail function]
    ; For Win32 only.
    SMTP = localhost
    smtp_port = 25

    ; For Win32 only.
    ;sendmail_from = me@example.com

    Can anyone advise me on the changes to make?

    PHP Code:
    <?php
    session_start
    ();
    /**
     * Purpose: Aids a user who's having problems logging in
     
     * Name: login_help.php
     * Programmer: Shannon Clarke
     * Version: 1.0
     * Date Created: July 17th 2007
     *
     */

      //Require the MySQL and Table Classes and the database login information 
      
    require_once('Database/MySQL.php');
      require_once(
    'logindata.php');
      require_once(
    'HTML/Table.php');
      
    // Include phpmailer class
      
    require_once ('ThirdParty/phpmailer/class.phpmailer.php');

      
    $db=& new MySQL($host,$dbUser,$dbPass,$dbName);

      include 
    'layout.php';  // Apply the CSS style layout and breadcrumb navigation
      
    include 'generate_random_password.php';

      if(isset(
    $_POST['getpassword'])){
        
        
    $email mysql_real_escape_string($_POST['email']);
        
    $passwd_sql "SELECT * FROM user " .
                      
    "WHERE user_email = '$email'";
               
        
    $passwd_dbquery = @mysql_query($passwd_sql);
        
    $passwd_dbfetch mysql_fetch_array($passwd_dbquery);
        
    $user_id $passwd_dbfetch['user_id'];

        if (
    mysql_num_rows($passwd_dbquery) == 0) {
          exit(
    '<p>There are no records of your account</p>');
        }else{
          
    $new_password get_rand_id(5);
          
          
    $new_passwd_sql= @mysql_query("UPDATE user 
                                         SET user_password = md5('
    $new_password') 
                                         WHERE user_email = '
    $email'");
          
          
    // phpmailer settings
          
    $yourName='Site administrator';
          
    $yourEmail='no-reply@uwi.tt';
          
    $subject='Your new password';
          
          
    $header='Here are your new login details with a new 
                randomly-generated password. Please change 
                your password to one you may easily remember.'
    ;
                 
          
    $message $header."\n\nLogin ID: ".$user_id.
                        
    "\nPassword: ".$new_password;
          
          
    mail$email"Subject: $subject",
                
    $message"From: $yourName$yourEmail);
          echo 
    "Thank you for using our mail form";        
          
        }
      }    
    ?>
      <h2>Forgotten Your Password?</h2>
      <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
        <p><label>Email address:</label> <input type="text" name="email" size='15' /></p>
        <p><input type="submit" name="getpassword" value="Get Password" /></p>
      </form>
    </div>
    </body>
    </html>

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Do you have an SMTP server running on the local system on port 25?


Bookmarks

Posting Permissions

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