Page 1 of 1

php mail errors

Posted: Mon Aug 15, 2011 9:53 am
by david_yg
I have the following codes in send_mail.php

Code: Select all


<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Send Email</title>
</head>

<body>
		
	  <?php	 
      // send mail code
           
      $name=$_GET["name"];
      $email=$_GET["email"];
      $message=$_GET["message"];
      
      ?>
      
      
      Name	  :  <?php echo $name; ?><br>
      email   :  <?php echo $email;?><br>
      message :  <?php echo $message;?><br>
      
	  
      <?php
	  //$to = 'david_yg20@yahoo.com';
	  $to = 'garudamedia@localhost';
	  $subject = 'e-mail feedback';
	  
	  ini_set('sendmail_from', 'admin@localhost');
	  ini_set('SMTP', 'localhost');
	  //ini_set('SMTP', 'smtp.mail.yahoo.co.id');
	  //ini_set('smtp_port','25');
	  
	  $message2 = "Name	  : " + $name + "email   : " + $email + "message : " + $message;  
	  
	  mail($to, $subject, $message2);
	  ?>
      Telah di kirim!
      
      
      
    
      
</body>
</html>



It suppose to send me feedback message regarding my webpage to my garudamedia@localhost e-mail.

1. It did work accept that the message only give me "0" number, why is that? What is the correct syntax ?

2. I tried another option which is to send the feedback e-mail to my david_yg20@yahoo.com e-mail. Yet, I have not find the correct codes to send the feedback message to my yahoo mail. I keep receiving 503 yahoo mail error authentication (or something similars). What is the correct syntax to send my feedback e-mail to my yahoo mail ?

Thanks.

Re: php mail errors

Posted: Mon Aug 15, 2011 10:03 am
by social_experiment
david_yg wrote:It did work accept that the message only give me "0" number, why is that? What is the correct syntax ?
The concatenation operator in php is the period (.)

Code: Select all

<?php
$message2 = "Name       : " + $name + "email   : " + $email + "message : " + $message;
// should be
$message2 = "Name : " . $name . " email : " . $email . " message: " . $message;
?>

Re: php mail errors

Posted: Mon Aug 15, 2011 10:34 am
by david_yg
What if I would like for each variable to be in different row. In html I would put <br>, how to do it in php ?

Thanks.

Re: php mail errors

Posted: Mon Aug 15, 2011 10:49 am
by social_experiment

Code: Select all

<?php
$message2 = "Name : " . $name . " email : " . $email . " message: " . $message;
//
$message2 = "Name : " . $name . "<br />";
$message2 .= "Email : " . $email . "<br />";
$message2 .= "Message: " . $message;
?>

Re: php mail errors

Posted: Mon Aug 15, 2011 11:16 am
by david_yg
it does not work.

Here is the result:

[text]Name : David<br />Email : david_yg20@yahoo.com<br />Message: Ini cuma percobaan penulisan e-mail. Barangkali bisa memenuhi kebutuhan pemilik website.[/text]

Re: php mail errors

Posted: Mon Aug 15, 2011 11:28 am
by Celauran
If you're sending the email as plain text, use \n instead.

Re: php mail errors

Posted: Mon Aug 15, 2011 1:41 pm
by social_experiment
Ah yeah, i somehow thought you were sending an html-type email.

Re: php mail errors

Posted: Tue Aug 16, 2011 10:57 am
by phphelpme

Code: Select all

$message2 = "Name: " . $name . "\n email: " . $email . "\n message: " . $message;
Or use \n\n for two line spaces.

Best wishes

Re: php mail errors

Posted: Tue Aug 16, 2011 12:44 pm
by phazorRise
use \n\n for two line spaces.
No.

See -
RFC 2821 standard for SMTP

To put new line separator in mail message body, it should be- CLRF ( "carriage return + line feed" ( "\r\n") ).

Also take look at -

http://en.wikipedia.org/wiki/Newline

Re: php mail errors

Posted: Tue Aug 16, 2011 12:53 pm
by phphelpme
lol you caught me out on a bad habbit there phazorrise... lol

Thanks for pointing that out and you are correct the RFC standard is \r\n although \n\n does accomplish the same end layout.

Thanks for pointing that out.

Best wishes

Re: php mail errors

Posted: Tue Aug 16, 2011 1:02 pm
by phazorRise
not using CRLF in headers might cause errors when using smtp specailly.

Re: php mail errors

Posted: Tue Aug 16, 2011 1:08 pm
by phphelpme
Yes I understand what you are refering to phaserrise but I think in this case the email is being sent as standard text not html. But you were right to correct me on the standards.

Best wishes