954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

need help in send and email

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,

god_1896
Light Poster
39 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

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 thevar keyword to initialize variables in PHP

Hope this helps, let us know

langsor
Posting Whiz
390 posts since Aug 2008
Reputation Points: 30
Solved Threads: 36
 

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

god_1896
Light Poster
39 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

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

langsor
Posting Whiz
390 posts since Aug 2008
Reputation Points: 30
Solved Threads: 36
 

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 :$

god_1896
Light Poster
39 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

No worries, glad you got it figured out.

:-)

langsor
Posting Whiz
390 posts since Aug 2008
Reputation Points: 30
Solved Threads: 36
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You