Mail format in php

designmantras
designmantras used Ask the Experts™
on
sir i have using mail function,mail function do work properly but html tag not read and show the html code in mail please tell how this possible..........
.........PHP code
                        $name=$_POST["txt_name"];
                  $email=$_POST["txt_email"];
                  $mobile=$_POST["txt_contactno"];
                  $feed_back=$_POST["txt_feedback"];
                  $subject = "Dear Customer,";
                  
                  
                  $text3="With Best Wishes.";
                  $text4="http://www.insurancetimes.in";
                  $headers = "From:subscribe@insurancetimes.in" ."\r\n";
                  $message="<html>
                                          <body>
                                         <h2>Thank you for send feedback on InsuranceTimes.in</h2>
                                         <p>Your Name:</p><br />".$name."
                                         <p>Your Email:</p><br />".$email."
                                          <p>Your Contact No.:</p><br />".$mobile."
                                        <p>Your Feed Back:</p><br />".$feed_back."
                                        <p>With Best Wishes.</p><br />
                                        <p>http://www.insurancetimes.in</p>
                                          </body>
                                       </html>";      

                  
                  mail($email,$subject,$message,$headers);
                  echo "Your mail successfully.";      
                  exit;      
                        }
                  }


Mail OUTPUT:


<html>
<body>
<h2>Thank you for send feedback on InsuranceTimes.in</h2>
<p>Your Name:</p><br />MANOJ
<p>Your Email:</p><br />manojpandey1988@gmail.com
<p>Your Contact No.:</p><br />9711350612
<p>Your Feed Back:</p><br />fine here!
<p>With Best Wishes.</p><br />
<p>http://www.insurancetimes.in</p>
</body>
</html>


Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
add these lines before you mail function call

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
Commented:
Please try to add "Content-type" in header
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From:subscribe@insurancetimes.in" ."\r\n";

Open in new window


 $name=$_POST["txt_name"];
                  $email=$_POST["txt_email"];
                  $mobile=$_POST["txt_contactno"];
                  $feed_back=$_POST["txt_feedback"];
                  $subject = "Dear Customer,";
                  
                  
                  $text3="With Best Wishes.";
                  $text4="http://www.insurancetimes.in";
                  $headers = "From:subscribe@insurancetimes.in" ."\r\n";
 
// To send HTML mail, the Content-type header must be set
$headers  .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 
                  $message="<html>
                                          <body>
                                         <h2>Thank you for send feedback on InsuranceTimes.in</h2>
                                         <p>Your Name:</p><br />".$name."
                                         <p>Your Email:</p><br />".$email."
                                          <p>Your Contact No.:</p><br />".$mobile."
                                        <p>Your Feed Back:</p><br />".$feed_back."
                                        <p>With Best Wishes.</p><br />
                                        <p>http://www.insurancetimes.in</p>
                                          </body>
                                       </html>";      
 
                  
                  mail($email,$subject,$message,$headers);
                  echo "Your mail successfully.";      
                  exit;      
                        }
                  }
 
 
Mail OUTPUT:

Open in new window

Commented:
try this:

                        $name=$_POST["txt_name"];
                  $email=$_POST["txt_email"];
                  $mobile=$_POST["txt_contactno"];
                  $feed_back=$_POST["txt_feedback"];
                  $subject = "Dear Customer,";
                  
                  
                  $text3="With Best Wishes.";
                  $text4="http://www.insurancetimes.in";
                  $headers = "From:subscribe@insurancetimes.in" ."\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
                  $message="<html>
                                          <body>
                                         <h2>Thank you for send feedback on InsuranceTimes.in</h2>
                                         <p>Your Name:</p><br />".$name."
                                         <p>Your Email:</p><br />".$email."
                                          <p>Your Contact No.:</p><br />".$mobile."
                                        <p>Your Feed Back:</p><br />".$feed_back."
                                        <p>With Best Wishes.</p><br />
                                        <p>http://www.insurancetimes.in</p>
                                          </body>
                                       </html>";      
 
                  
                  mail($email,$subject,$message,$headers);
                  echo "Your mail successfully.";      
                  exit;      
                        }
                  }

Open in new window

Commented:
hahaa. I think that's pretty conclusive :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial