Getting empty email message using PHP -


i sending email using php class. it's send email message in gmail email account it's showing me empty message. don't understand why it's showing me empty message content. it's showy unknown sender , empty message body. here pictures shwoing in gmail account. can please me it.

your more appreciate :)

enter image description here , enter image description here

here full code i'm using send email using php.

<?php  $name=""; $from=""; $message="";  if(isset($_post['submit'])){  $name=mysql_real_escape_string($_post['name']); $from=mysql_real_escape_string($_post['email']); $message=mysql_real_escape_string($_post['comments']); $to="myemail@gmail.com"; // add e-mail here  include("library/send_email.php");   }   ?> 

send_emaiil.php page

<?php require_once("class_email_sender.php"); $send_email= new class_email_sender($name,$from,$to,$message); $send_email->send_email(); ?> 

class_email_sender.php page

<?php  class class_email_sender{ private $name;  private $from; private $to; private $to_email; private $subject; private $headers; private $mail_message;  public function __construct($name,$from,$to_email,$mail_message){  $this->name=$name; $this->from=$from; $this->to_email=$to_email; $this->mail_message=$mail_message; }  public function send_email(){  $this->to=$this->to_email; //$this->headers="from : $this->from<$this->from>"; $this->headers = 'from:'.$this->from. "\r\n" .         'reply-to: webmaster@example.com' . "\r\n" .         'x-mailer: php/' . phpversion();  $this->subject="contact message site"; $this->message="name :" .$this->name. "\n"; $this->message.="email :" .$this->from."\n\n"; $this->message.="message :" . $this->mail_message."\n\n"; mail($this->to_email,$this->subject,$this->message,$this->headers);  echo '<script>alert("thanks mail.we notify shortly") </script>'; }    } ?> 

for example here code worked me

<?php  $username = $_post["username"]; //email address want 'appear' come  $email = $_post["email"];   if(strlen($username) && strlen($email)) {      $mailtext ="the contact details: <br>"; }               $mailtext=$mailtext."<table border=1 cellspacing=0 cellpadding=0>";                   while(list($key, $val)= each($_post))                    {                     $mailtext=$mailtext."<tr><td width=50%>";                      $mailtext=$mailtext."<b>".$key."</b></td>";                     $mailtext=$mailtext."<td width=50%>";                        $mailtext=$mailtext.$val;                     $mailtext=$mailtext."</td></tr>";                 }  $to = "youremailid.com"; if(strlen($username) && strlen($email)) { $subject = "your subject"; //subject line   $headers .= "from:yourmail.com\n";     $headers .= "x-sender:  yourheader.com\n";      $headers .= "content-type: text/html; charset=iso-8859-1\n";         // mime type $mailforms = mail($to, $subject, $mailtext, $headers); } ?> 

try keep acc ur code , check


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -