title: How to send a html designed mail through mail function in PHP
body: <p>from morning I have been trying but at last I have to put this at stackoverflow. I have been trying to send HTML mail through php when when i see my mail i get the HTML coads exactly not the beautifully designed mail</p>
  
  <pre><code>    &lt;?php
  $email = $_POST["email"];
  $to = $email;
  $from = "arshkapoor2015@gmail.com";
  $subject = "Your thebigmall coupon code";
  $headers = "From:" . $from;
  ob_start();
  ?&gt;
  
  
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;p&gt;
              &amp;nbsp;&lt;/p&gt;
          &lt;div style="font-size: small; width: 797.4166870117188px; background-color: rgb(236, 236, 236); margin: 0px; padding: 0px; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; "&gt;
              &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt;
                  &lt;tbody&gt;
                      &lt;tr style="border-collapse: collapse; "&gt;
                          &lt;td align="center" bgcolor="#ececec" style="border-collapse: collapse; "&gt;
                              &lt;table border="0" cellpadding="0" cellspacing="0" style="margin: 0px 10px; " width="640"&gt;
                                  &lt;tbody&gt;
                                      &lt;tr style="border-collapse: collapse; "&gt;
                                          &lt;td height="20" style="border-collapse: collapse; " width="640"&gt;
                                              &amp;nbsp;&lt;/td&gt;
                                      &lt;/tr&gt;
                                      &lt;tr style="border-collapse: collapse; "&gt;
                                          &lt;td style="border-collapse: collapse; " width="640"&gt;
                                              &lt;table bgcolor="#00707b" border="0" cellpadding="0" cellspacing="0" style="border-top-left-radius: 6px; border-top-right-radius: 6px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; background-color: rgb(4, 57, 72); color: rgb(231, 203, 163); " width="640"&gt;
                                                  &lt;tbody&gt;
                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                          &lt;td style="border-collapse: collapse; " width="15"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                          &lt;td align="left" style="border-collapse: collapse; " valign="middle" width="350"&gt;
                                                              &lt;table border="0" cellpadding="0" cellspacing="0" width="350"&gt;
                                                                  &lt;tbody&gt;
                                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                                          &lt;td height="8" style="border-collapse: collapse; " width="350"&gt;
                                                                              &amp;nbsp;&lt;/td&gt;
                                                                      &lt;/tr&gt;
                                                                  &lt;/tbody&gt;
                                                              &lt;/table&gt;
                                                              &lt;div style="font-size: 12px; "&gt;
                                                                  &lt;a href="http://www.thebigmall.co.in" style="font-weight: bold; color: rgb(231, 203, 163); text-decoration: none; " target="_blank"&gt;Web Version&lt;/a&gt;&lt;/div&gt;
                                                              &lt;table border="0" cellpadding="0" cellspacing="0" width="350"&gt;
                                                                  &lt;tbody&gt;
                                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                                          &lt;td height="8" style="border-collapse: collapse; " width="350"&gt;
                                                                              &amp;nbsp;&lt;/td&gt;
                                                                      &lt;/tr&gt;
                                                                  &lt;/tbody&gt;
                                                              &lt;/table&gt;
                                                          &lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " width="30"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                          &lt;td align="right" style="border-collapse: collapse; " valign="middle" width="255"&gt;
                                                              &lt;table border="0" cellpadding="0" cellspacing="0" width="255"&gt;
                                                                  &lt;tbody&gt;
                                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                                          &lt;td height="8" style="border-collapse: collapse; " width="255"&gt;
                                                                              &amp;nbsp;&lt;/td&gt;
                                                                      &lt;/tr&gt;
                                                                  &lt;/tbody&gt;
                                                              &lt;/table&gt;
                                                              &lt;table border="0" cellpadding="0" cellspacing="0"&gt;
                                                                  &lt;tbody&gt;
                                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                                          &lt;td style="border-collapse: collapse; " valign="middle"&gt;
                                                                              &lt;a href="http://preview.createsend3.com/t/j-fb-wukdik-l-t/" rel="cs_facebox" style="font-weight: bold; color: rgb(231, 203, 163); text-decoration: none; " target="_blank"&gt;&lt;img alt="Facebook icon" border="0" height="14" src="https://img.createsend1.com/img/templatebuilder/like-glyph.png" style="min-height: auto; line-height: 13px; outline-style: none; display: block; " width="8" /&gt;&lt;/a&gt;&lt;/td&gt;
                                                                          &lt;td style="border-collapse: collapse; " width="3"&gt;
                                                                              &amp;nbsp;&lt;/td&gt;
                                                                          &lt;td style="border-collapse: collapse; " valign="middle"&gt;
                                                                              &lt;div style="font-size: 12px; "&gt;
                                                                                  &lt;a href="http://preview.createsend3.com/t/j-fb-wukdik-l-i/" rel="cs_facebox" style="font-weight: bold; color: rgb(231, 203, 163); text-decoration: none; " target="_blank"&gt;Like&lt;/a&gt;&lt;/div&gt;
                                                                          &lt;/td&gt;
                                                                          &lt;td style="border-collapse: collapse; " width="10"&gt;
                                                                              &amp;nbsp;&lt;/td&gt;
                                                                          &lt;td style="border-collapse: collapse; " valign="middle"&gt;
                                                                              &lt;a href="http://client.forwardtomyfriend.com/j-l-2AD73FFF-wukdik-l-d" lang="en" style="font-weight: bold; color: rgb(231, 203, 163); text-decoration: none; " target="_blank"&gt;&lt;img alt="Forward icon" border="0" height="14" src="https://img.createsend1.com/img/templatebuilder/forward-glyph.png" style="min-height: auto; line-height: 13px; outline-style: none; display: block; " width="19" /&gt;&lt;/a&gt;&lt;/td&gt;
                                                                          &lt;td style="border-collapse: collapse; " width="3"&gt;
                                                                              &amp;nbsp;&lt;/td&gt;
                                                                          &lt;td style="border-collapse: collapse; " valign="middle"&gt;
                                                                              &lt;div style="font-size: 12px; "&gt;
                                                                                  &lt;a href="http://client.forwardtomyfriend.com/j-l-2AD73FFF-wukdik-l-h" lang="en" style="font-weight: bold; color: rgb(231, 203, 163); text-decoration: none; " target="_blank"&gt;Forward&lt;/a&gt;&lt;/div&gt;
                                                                          &lt;/td&gt;
                                                                      &lt;/tr&gt;
                                                                  &lt;/tbody&gt;
                                                              &lt;/table&gt;
                                                              &lt;table border="0" cellpadding="0" cellspacing="0" width="255"&gt;
                                                                  &lt;tbody&gt;
                                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                                          &lt;td height="8" style="border-collapse: collapse; " width="255"&gt;
                                                                              &amp;nbsp;&lt;/td&gt;
                                                                      &lt;/tr&gt;
                                                                  &lt;/tbody&gt;
                                                              &lt;/table&gt;
                                                          &lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " width="15"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                      &lt;/tr&gt;
                                                  &lt;/tbody&gt;
                                              &lt;/table&gt;
                                          &lt;/td&gt;
                                      &lt;/tr&gt;
                                      &lt;tr style="border-collapse: collapse; "&gt;
                                          &lt;td align="center" bgcolor="#00707b" style="border-collapse: collapse; " width="640"&gt;
                                              &lt;table border="0" cellpadding="0" cellspacing="0" width="640"&gt;
                                                  &lt;tbody&gt;
                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                          &lt;td style="border-collapse: collapse; " width="30"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                          &lt;td height="30" style="border-collapse: collapse; " width="580"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " width="30"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                      &lt;/tr&gt;
                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                          &lt;td style="border-collapse: collapse; " width="30"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " width="580"&gt;
                                                              &lt;div align="center"&gt;
                                                                  &lt;p style="color: rgb(231, 203, 163); font-family: 'Helvetica Neue', Arial, Helvetica, Geneva, sans-serif; font-size: 36px; margin-top: 0px; margin-bottom: 30px; "&gt;
                                                                      &lt;strong&gt;TheBigMall Coupon code !&lt;/strong&gt;&lt;/p&gt;
                                                              &lt;/div&gt;
                                                          &lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " width="30"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                      &lt;/tr&gt;
                                                  &lt;/tbody&gt;
                                              &lt;/table&gt;
                                          &lt;/td&gt;
                                      &lt;/tr&gt;
                                      &lt;tr style="border-collapse: collapse; "&gt;
                                          &lt;td bgcolor="#ffffff" height="30" style="border-collapse: collapse; " width="640"&gt;
                                              &amp;nbsp;&lt;/td&gt;
                                      &lt;/tr&gt;
                                      &lt;tr style="border-collapse: collapse; "&gt;
                                          &lt;td bgcolor="#ffffff" style="border-collapse: collapse; " width="640"&gt;
                                              &lt;table border="0" cellpadding="0" cellspacing="0" width="640"&gt;
                                                  &lt;tbody&gt;
                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                          &lt;td style="border-collapse: collapse; " width="30"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " width="580"&gt;
                                                              &lt;table border="0" cellpadding="0" cellspacing="0" width="580"&gt;
                                                                  &lt;tbody&gt;
                                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                                          &lt;td style="border-collapse: collapse; " width="580"&gt;
                                                                              &lt;h1 align="left" style="font-size: 18px; line-height: 24px; color: rgb(154, 150, 97); font-weight: bold; margin-top: 0px; margin-bottom: 18px; "&gt;
                                                                                  25% off on modular kitchens (Faizabad Road)&lt;/h1&gt;
                                                                              &lt;div align="left" style="font-size: 13px; line-height: 18px; color: rgb(68, 68, 68); margin-top: 0px; margin-bottom: 18px; "&gt;
                                                                                  &lt;p style="margin-bottom: 15px; "&gt;
                                                                                      &lt;strong&gt;Offer Details&lt;/strong&gt;&lt;/p&gt;
                                                                                  &lt;p style="margin-bottom: 15px; "&gt;
                                                                                      Make your kitchen a beautiful place to cook with RECENT KITCHEN WORLD&lt;/p&gt;
                                                                                  &lt;p style="margin-bottom: 15px; "&gt;
                                                                                      Get 25% discount on total billing amount on modular kitchens manufacturing.&amp;nbsp;&lt;/p&gt;
                                                                                  &lt;p style="margin-bottom: 15px; "&gt;
                                                                                      Our Products:&lt;br style="line-height: 13px; " /&gt;
                                                                                      Marine Ply Shutter (Weather Proof)&lt;br style="line-height: 13px; " /&gt;
                                                                                      Marine Ply Carcass (Weather Proof)&lt;br style="line-height: 13px; " /&gt;
                                                                                      Acrylic shutter&lt;br style="line-height: 13px; " /&gt;
                                                                                      Civil work&lt;br style="line-height: 13px; " /&gt;
                                                                                      Chimney&lt;br style="line-height: 13px; " /&gt;
                                                                                      150 Colours available&lt;/p&gt;
                                                                                  &lt;p style="margin-bottom: 15px; "&gt;
                                                                                      Offer for limited period. So don&amp;#39;t leave this opportunity &amp;amp; make your kitchen beautiful !!!&lt;/p&gt;
                                                                              &lt;/div&gt;
                                                                          &lt;/td&gt;
                                                                      &lt;/tr&gt;
                                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                                          &lt;td height="10" style="border-collapse: collapse; " width="580"&gt;
                                                                              &amp;nbsp;&lt;/td&gt;
                                                                      &lt;/tr&gt;
                                                                  &lt;/tbody&gt;
                                                              &lt;/table&gt;
                                                              &lt;table border="0" cellpadding="0" cellspacing="0" width="580"&gt;
                                                                  &lt;tbody&gt;
                                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                                          &lt;td style="border-collapse: collapse; " width="580"&gt;
                                                                              &lt;p align="left" style="font-size: 18px; line-height: 24px; color: rgb(154, 150, 97); font-weight: bold; margin-top: 0px; margin-bottom: 18px; "&gt;
                                                                                  Coupon code !&lt;/p&gt;
                                                                              &lt;div align="left" style="font-size: 13px; line-height: 18px; color: rgb(68, 68, 68); margin-top: 0px; margin-bottom: 18px; "&gt;
                                                                                  &lt;h1 style="margin-bottom: 15px; text-align: center; "&gt;
                                                                                      12345$randstr$randstr2&lt;/h1&gt;
                                                                                  &lt;p style="margin-bottom: 15px; "&gt;
                                                                                      &amp;nbsp;&lt;/p&gt;
                                                                              &lt;/div&gt;
                                                                          &lt;/td&gt;
                                                                      &lt;/tr&gt;
                                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                                          &lt;td height="10" style="border-collapse: collapse; " width="580"&gt;
                                                                              &amp;nbsp;&lt;/td&gt;
                                                                      &lt;/tr&gt;
                                                                  &lt;/tbody&gt;
                                                              &lt;/table&gt;
                                                              &lt;table border="0" cellpadding="0" cellspacing="0" width="580"&gt;
                                                                  &lt;tbody&gt;
                                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                                          &lt;td style="border-collapse: collapse; " width="580"&gt;
                                                                              &lt;p align="left" style="font-size: 18px; line-height: 24px; color: rgb(154, 150, 97); font-weight: bold; margin-top: 0px; margin-bottom: 18px; "&gt;
                                                                                  Address :&lt;/p&gt;
                                                                              &lt;div align="left" style="font-size: 13px; line-height: 18px; color: rgb(68, 68, 68); margin-top: 0px; margin-bottom: 18px; "&gt;
                                                                                  &lt;p style="text-align: center; margin-bottom: 15px; "&gt;
                                                                                      Store Address :Kamta Check Post, Faizabad Road, Opp. Kamta Petrol Pump, Lucknow.&lt;br style="line-height: 13px; " /&gt;
                                                                                      City :Lucknow&lt;br style="line-height: 13px; " /&gt;
                                                                                      Contact No.9415255816, 9721961276, 9918404211&lt;br style="line-height: 13px; " /&gt;
                                                                                      &lt;span style="color: rgb(255, 0, 0); "&gt;Offers valid for 48 hours only.&lt;/span&gt;&lt;/p&gt;
                                                                              &lt;/div&gt;
                                                                          &lt;/td&gt;
                                                                      &lt;/tr&gt;
                                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                                          &lt;td height="10" style="border-collapse: collapse; " width="580"&gt;
                                                                              &amp;nbsp;&lt;/td&gt;
                                                                      &lt;/tr&gt;
                                                                  &lt;/tbody&gt;
                                                              &lt;/table&gt;
                                                          &lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " width="30"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                      &lt;/tr&gt;
                                                  &lt;/tbody&gt;
                                              &lt;/table&gt;
                                          &lt;/td&gt;
                                      &lt;/tr&gt;
                                      &lt;tr style="border-collapse: collapse; "&gt;
                                          &lt;td bgcolor="#ffffff" height="15" style="border-collapse: collapse; " width="640"&gt;
                                              &amp;nbsp;&lt;/td&gt;
                                      &lt;/tr&gt;
                                      &lt;tr style="border-collapse: collapse; "&gt;
                                          &lt;td style="border-collapse: collapse; " width="640"&gt;
                                              &lt;table bgcolor="#043948" border="0" cellpadding="0" cellspacing="0" style="border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 6px; border-bottom-left-radius: 6px; background-color: rgb(4, 57, 72); color: rgb(226, 226, 226); " width="640"&gt;
                                                  &lt;tbody&gt;
                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                          &lt;td style="border-collapse: collapse; " width="30"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                          &lt;td height="30" style="border-collapse: collapse; " width="360"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " width="60"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " width="160"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " width="30"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                      &lt;/tr&gt;
                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                          &lt;td style="border-collapse: collapse; " width="30"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " valign="top" width="360"&gt;
                                                              &lt;p align="left" style="font-size: 12px; line-height: 15px; margin-top: 0px; margin-bottom: 15px; "&gt;
                                                                  &amp;nbsp;&lt;/p&gt;
                                                              &lt;p align="left" style="font-size: 12px; line-height: 15px; margin-top: 0px; margin-bottom: 15px; "&gt;
                                                                  All Rights Reserved &amp;gt; TheBigMall.co.in - Great discounts in your city&lt;/p&gt;
                                                          &lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " width="60"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " valign="top" width="160"&gt;
                                                              &lt;p align="right" style="font-size: 11px; line-height: 16px; margin-top: 0px; margin-bottom: 15px; color: rgb(231, 203, 163); "&gt;
                                                                  &amp;nbsp;&lt;/p&gt;
                                                          &lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " width="30"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                      &lt;/tr&gt;
                                                      &lt;tr style="border-collapse: collapse; "&gt;
                                                          &lt;td style="border-collapse: collapse; " width="30"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                          &lt;td height="15" style="border-collapse: collapse; " width="360"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " width="60"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " width="160"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                          &lt;td style="border-collapse: collapse; " width="30"&gt;
                                                              &amp;nbsp;&lt;/td&gt;
                                                      &lt;/tr&gt;
                                                  &lt;/tbody&gt;
                                              &lt;/table&gt;
                                          &lt;/td&gt;
                                      &lt;/tr&gt;
                                      &lt;tr style="border-collapse: collapse; "&gt;
                                          &lt;td height="60" style="border-collapse: collapse; " width="640"&gt;
                                              &amp;nbsp;&lt;/td&gt;
                                      &lt;/tr&gt;
                                  &lt;/tbody&gt;
                              &lt;/table&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/tbody&gt;
              &lt;/table&gt;
              &lt;img border="0" height="1" src="https://createsend3.com/t/j-o-wukdik-l/o.gif" style="min-height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important; line-height: 13px; outline-style: none; display: block; " width="1" /&gt;&lt;/div&gt;
          &lt;div&gt;
              &amp;nbsp;&lt;/div&gt;
          &lt;p&gt;
              &amp;nbsp;&lt;/p&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;?
  $message = ob_get_clean();
  
  
  mail($to,$subject,$message,$headers);
  echo "Mail Sent.";
  ?&gt;
  </code></pre>