hi all;
suposed to be this question has been solve, perhaps sory if i need to ask again.

I found a code of send and email using with php classes; but there is something wrong with it.
here is the whole code.

class request {
    
	var $email;
	var $senderName;
	var $senderPhone;
	var $senderEmail;
    var $senderSubject;
    var $senderMessage;
    var $returnEmail;
    var $header;
    var $type         = "text/plain";
    var $characterSet = "iso-8859-1";
	
	function createHeader() {
	
        $from   = "From: $this->senderName <$this->senderEmail>\r\n";
        $returnEmail = "Reply-To: $this->returnEmail\r\n";    
        $params = "MIME-Version: 1.0\r\n";
        $params .= "Content-type: $this->type; charset=$this->characterSet\r\n";
        
        $this->header = $from.$returnEmail.$params;
        return $this->header;
    }
	
	function sendEmail(){

        $this->createHeader();
		
        @mail($this->email,$this->senderSubject,$this->senderMessage,$this->header);
 
    }

}

      $mail = new request();
        
      $mail->email          = $_POST['email'];
      $mail->senderName   	= $_POST['senderName'];
      $mail->senderEmail  	= $_POST['senderEmail'];
      $mail->senderPhone 	= $_POST['senderPhone'];
      $mail->senderSubject  = $_POST['senderSubject'];
      $mail->senderMessage  = $_POST['senderMessage'];
	  
      if ($mail->sendEmail()) {
	  
        echo "Thanks for your message!";

      } else {
        echo "Sending email was failed!";
      }

when i run this code. there is an error on the screen,

Warning: mail() [function.mail]: SMTP server response: 503 valid RCPT command must precede DATA in F:\Program Files

please help me to fixed this error. regards to all,

Recommended Answers

All 5 Replies

Member Avatar for langsor

Before taking a deeper look, it appears that there's been a mixup of PHP and JavaScript variable types ... fix this first and if it still doesn't work let us know.

var $email;
	var $senderName;
	var $senderPhone;
	var $senderEmail;
    var $senderSubject;
    var $senderMessage;
    var $returnEmail;
    var $header;
    var $type         = "text/plain";
    var $characterSet = "iso-8859-1";

... should be ...

$email;
 $senderName;
 $senderPhone;
 $senderEmail;
 $senderSubject;
 $senderMessage;
 $returnEmail;
 $header;
 $type = "text/plain";
 $characterSet = "iso-8859-1";

... since you don't use the var keyword to initialize variables in PHP

Hope this helps, let us know

hi, well i found somthing difference, this is more getting worry of me.

Member Avatar for langsor

I'm providing a lot of wrong information today, I guess I should shut it down for the night.

But first I did a little investigation into your problem -- and I guess you do use the var keyword in pre-PHP5 class definitions (my bad) -- but to answer your question, many mail systems require you to receive email through the system before you can send mail through the system ... this is to prevent people using the system to relay SPAM and related activities.

Looks like your error message is coming from the mail server and not PHP directly, and that the above issue is your problem.

So do a "receive" before trying to "send" with your mail server and see if that fixes the problem.

Hope this helps

hi; yes maybe your right;

but i finally solve this problem. actually its my mistake, I forgot to post the default email of the reciepient. Im sory :$

Member Avatar for langsor

No worries, glad you got it figured out.

:-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.