Hello all, I want to send a html table in php mail . <html> <p align='center'> <img src='http://www.mydomain.com/Images/Logo.jpg' width='210' height='45'> </p> <table cellspacing="4" cellpadding="4" border="1" align="center"> <tr> <td align="center">Name</td> <td align="center"> John</td> <td align="center">Age</td> <td align="center">20</td> </tr> <tr> <td align="center">Empid</td> <td align="center">0014 </td> <td align="center">Depart</td> <td align="center">IT</td> </tr> <tr> <td align="center">Salary</td> <td align="center">20000</td> <td align="center">Country</td> <td align="center">US</td> </tr> </table> </html> Code (markup): on sending it simply in the message & then opening the mail , the code is displayed in place of structured table. Please help me to send html in php mail so that on opening a structured table can be displayed in the recieved mail . Thanks & regards.
<?php $to = "you@gmail.com"; $subject = "html table"; $message = ' <html> <table cellspacing="4" cellpadding="4" border="1" align="center"> <tr> <td align="center">Name</td> <td align="center"> John</td> <td align="center">Age</td> <td align="center">20</td> </tr> <tr> <td align="center">Empid</td> <td align="center">0014 </td> <td align="center">Depart</td> <td align="center">IT</td> </tr> <tr> <td align="center">Salary</td> <td align="center">20000</td> <td align="center">Country</td> <td align="center">US</td> </tr> </table> </html> '; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= 'From: <me@me.com>' . "\r\n"; mail($to,$subject,$message,$headers); ?> Code (markup):
Hello javaongsan, Thanks for your precious reply. on sending the mail according your suggestion, on opening the recieved the mail html code itself is displaying , & if i change its mode from settings to html view then the data is displayed but without inside any table . Please suggest how these can be recieved correctly . Thanks.
Hello javaongsan, I am getting the text code like: Content-type:text/html;charset=iso-8859-1 From: <myname@mysite.com> <html> <table cellspacing="4" cellpadding="4" border="1" align="center"> <tr> <td align="center">Name</td> <td align="center"> John</td> <td align="center">Age</td> <td align="center">20</td> </tr> <tr> <td align="center">Empid</td> <td align="center">0014 </td> <td align="center">Depart</td> <td align="center">IT</td> </tr> <tr> <td align="center">Salary</td> <td align="center">20000</td> <td align="center">Country</td> <td align="center">US</td> </tr> </table> </html> Code (markup): in the recieved mail instead of table & data, Please help me to correct these problem. Thanks.
its bery easy just use this header $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
If the problem persists, make sure the your text editor is formatted to 'Unix' or 'Linux' and not 'Windows.' The Exchange mail server rejects Windows line return characters in HTML as being illegal and instead displays the HTML as raw text in Outlook. It's rare, but it happens.