473,473 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

29 New Member
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




Expand|Select|Wrap|Line Numbers
  1.  
  2.  function procForgotPass(){
  3.  
  4.       global $database, $session, $mailer, $form;
  5.  
  6.       /* Username error checking */
  7.  
  8.       $subuser = $_POST['user'];
  9.  
  10.       $field = "user";  //Use field name for username
  11.  
  12.       if(!$subuser || strlen($subuser = trim($subuser)) == 0){
  13.  
  14.          $form->setError($field, "* Username not entered<br>");
  15.  
  16.       }
  17.  
  18.       else{
  19.  
  20.          /* Make sure username is in database */
  21.  
  22.          $subuser = stripslashes($subuser);
  23.  
  24.          if(strlen($subuser) < 5 || strlen($subuser) > 30 ||
  25.  
  26.             !eregi("^([0-9a-z])+$", $subuser) ||
  27.  
  28.             (!$database->usernameTaken($subuser))){
  29.  
  30.             $form->setError($field, "* Username does not exist<br>");
  31.  
  32.          }
  33.  
  34.       }
  35.  
  36.  
  37.  
  38.       /* Errors exist, have user correct them */
  39.  
  40.       if($form->num_errors > 0){
  41.  
  42.          $_SESSION['value_array'] = $_POST;
  43.  
  44.          $_SESSION['error_array'] = $form->getErrorArray();
  45.  
  46.       }
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.       /* Generate new password and email it to user */
  57.  
  58.       else
  59.  
  60.       // make sure seesion starts before
  61.  
  62.       header("Location: ".$session->referrer);
  63.  
  64.  
  65.  
  66.       {
  67.  
  68.          /* Generate new password */
  69.  
  70.          $newpass = $session->generateRandStr(8);
  71.  
  72.  
  73.  
  74.          /* Get email of user */
  75.  
  76.          $usrinf = $database->getUserInfo($subuser);
  77.  
  78.          $email  = $usrinf['email'];
  79.  
  80.  
  81.  
  82.          /* Attempt to send the email with new password */
  83.  
  84.          if($mailer->sendNewPass($subuser,$email,$newpass)){
  85.  
  86.             /* Email sent, update database */
  87.  
  88.             $database->updateUserField($subuser, "password", md5($newpass));
  89.  
  90.             $_SESSION['forgotpass'] = true;
  91.  
  92.          }
  93.  
  94.          /* Email failure, do not change password */
  95.  
  96.          else{
  97.  
  98.             $_SESSION['forgotpass'] = false;
  99.  
  100.          }
  101.  
  102.       }
  103.  
  104.  
  105.  
  106.  
  107.  
  108.    } 


this is my mail set


Expand|Select|Wrap|Line Numbers
  1.  
  2.  function sendNewPass($user, $email, $pass){
  3.  
  4.       $from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
  5.  
  6.       $subject = "Elite ticket master - Your new password";
  7.  
  8.       $body = $user.",\n\n"
  9.  
  10.              ."We've generated a new password for you at your "
  11.  
  12.              ."request, you can use this new password with your "
  13.  
  14.              ."username to log in to Eliteticketsevents Site.\n\n"
  15.  
  16.              ."Username: ".$user."\n"
  17.  
  18.              ."New Password: ".$pass."\n\n"
  19.  
  20.              ."It is recommended that you change your password "
  21.  
  22.              ."to something that is easier to remember, which "
  23.  
  24.              ."can be done by going to the My Account page "
  25.  
  26.              ."after signing in.\n\n"
  27.  
  28.              ."- EliteTickets's Site";
  29.  
  30.  
  31.  
  32.  
  33.  
  34.               $server = "smtp.virgin.net";
  35.  
  36.  ini_set("SMTP",$server);
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.        return mail($email,$subject,$body,$from);
Apr 23 '10 #1
1 4032
Atli
5,058 Recognized Expert Expert
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:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. else
  3. echo "One";
  4.  
  5. {
  6.     echo "Two";
  7.     echo "Three";
  8. }
  9. ?>
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:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. else
  3. {
  4.     echo "One";
  5.     echo "Two";
  6.     echo "Three";
  7. }
  8. ?>
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.
Apr 23 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Stuart Palmer | last post by:
I have had for sometime a problem getting cdo.message to work, so I have given up on this and tried to test a form on my localhost machine using CDONTS again (this used to work) I have win 2000...
3
by: NurAzije | last post by:
Hi, I have a huge mailling list and want to check which mails are real and which does not exists to reduce the size, is there a function which will check if mail@mailserver.somthing exists or not...
6
by: John J. Hughes II | last post by:
I have a service that needs to send e-mail alerts. I have been attempting to use the System.Net.Mail function from .NET but this seems to require the IIS be installed and running. Since some of...
14
by: Mattia | last post by:
I have a very big problem. I must send a single mail to multiple receivers. The number of receivers are very big: approximately 6000 users, but this number increase each year. I find a lot of...
1
by: ashim.chowdhury | last post by:
While using mail() function in PHP I am getting thjis error Warning: mail(): SMTP server response: 505 5.7.3 Must issue a STARTTLS command first I have used...
34
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow...
0
by: Bob | last post by:
There seems to be a problem when using System.Net.Mail to send emails to multiple recipients when one or more of the recipient addresses is incorrect and the destination SMTP server is using...
11
by: ibiza | last post by:
Hi all, I am trying to use the System.Net.Mail class for the first time, with ASP.NET 2.0. I setup everything according to http://www.codeproject.com/aspnet/EasySMTP_package.asp, which gives...
3
by: Jason Huang | last post by:
Hi, In my C# Windows form project, I can receieve the mail from the C# code, however, it's EMPTY in the MAIL FROM: Would someone give me some advice? string Data; byte szData; TcpClient...
10
by: crazycooter | last post by:
I found an old thread on this (http://groups.google.com/group/alt.php/ browse_thread/thread/751edb9c723316c4/ea9bf92a9c6b807c?lnk=gst&q=mail() +duplicate&rnum=7#ea9bf92a9c6b807c), but there didnt...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.