Warning: mail() [function.mail]: SMTP server response: 503 valid RCPT command must pr

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lisa007
    New Member
    • Apr 2010
    • 29

    #1

    Warning: mail() [function.mail]: SMTP server response: 503 valid RCPT command must pr

    Warning: mail() [function.mail]: SMTP server response: 503 valid RCPT command must precede DATA on

    whenever user click on to get new password but doesnt fill in the username field it shows that message i have set up the server because if user put username the form works but if left blanck this error message keeps coming up




    Code:
     function procForgotPass(){
    
          global $database, $session, $mailer, $form;
    
          /* Username error checking */
    
          $subuser = $_POST['user'];
    
          $field = "user";  //Use field name for username
    
          if(!$subuser || strlen($subuser = trim($subuser)) == 0){
    
             $form->setError($field, "* Username not entered<br>");
    
          }
    
          else{
    
             /* Make sure username is in database */
    
             $subuser = stripslashes($subuser);
    
             if(strlen($subuser) < 5 || strlen($subuser) > 30 ||
    
                !eregi("^([0-9a-z])+$", $subuser) ||
    
                (!$database->usernameTaken($subuser))){
    
                $form->setError($field, "* Username does not exist<br>");
    
             }
    
          }
    
          
    
          /* Errors exist, have user correct them */
    
          if($form->num_errors > 0){
    
             $_SESSION['value_array'] = $_POST;
    
             $_SESSION['error_array'] = $form->getErrorArray();
    
          }
    
          
    
          
    
          
    
          
    
          /* Generate new password and email it to user */
    
          else
    
          // make sure seesion starts before
    
          header("Location: ".$session->referrer);
    
          
    
          {
    
             /* Generate new password */
    
             $newpass = $session->generateRandStr(8);
    
             
    
             /* Get email of user */
    
             $usrinf = $database->getUserInfo($subuser);
    
             $email  = $usrinf['email'];
    
             
    
             /* Attempt to send the email with new password */
    
             if($mailer->sendNewPass($subuser,$email,$newpass)){
    
                /* Email sent, update database */
    
                $database->updateUserField($subuser, "password", md5($newpass));
    
                $_SESSION['forgotpass'] = true;
    
             }
    
             /* Email failure, do not change password */
    
             else{
    
                $_SESSION['forgotpass'] = false;
    
             }
    
          }
    
          
    
          
    
       }


    this is my mail set


    Code:
     function sendNewPass($user, $email, $pass){
    
          $from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
    
          $subject = "Elite ticket master - Your new password";
    
          $body = $user.",\n\n"
    
                 ."We've generated a new password for you at your "
    
                 ."request, you can use this new password with your "
    
                 ."username to log in to Eliteticketsevents Site.\n\n"
    
                 ."Username: ".$user."\n"
    
                 ."New Password: ".$pass."\n\n"
    
                 ."It is recommended that you change your password "
    
                 ."to something that is easier to remember, which "
    
                 ."can be done by going to the My Account page "
    
                 ."after signing in.\n\n"
    
                 ."- EliteTickets's Site";
    
                 
    
         
    
                  $server = "smtp.virgin.net";
    
     ini_set("SMTP",$server);
    
     
    
     
    
    
    
           return mail($email,$subject,$body,$from);
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    Lines #58 to #66 in your first example. Assuming you meant to have the block starting on line #66 executed on the else condition on line #58, you need to move the header on line #62 inside the block.

    IF and ELSE conditions execute ONLY the first line of code directly following them. When this line is the start of a code block, the entire block is executed.

    That is, if you have this else clause:
    [code=php]<?php
    else
    echo "One";

    {
    echo "Two";
    echo "Three";
    }
    ?>[/code]
    The "One" will be printed ONLY if the else clause is triggered, but the "Two" and "Three" will always be executed.

    This, on the other hand:
    [code=php]<?php
    else
    {
    echo "One";
    echo "Two";
    echo "Three";
    }
    ?>[/code]
    Here none of the echoes are executed unless the else clause is triggered.


    Also, the sendNewPass function always sends the mail, even if the email is invalid. You should make sure the email is valid before sending the mail, or you risk sending an empty email and running into errors like these.

    Comment

    Working...