Hi there, I just want to use a couple of styles to manage the type and include the style sheet in the email, But after getting email in my Gmail inbox, It is showing email with all html code.(All tags & styles) Can anyone let me know, how to use css in email? Have a look on code bellow: $to=$data[2]; $subject ="New Newsletter from couponguru.com"; $headers = 'From: couponguru@gmail.com' . "\r\n" . 'Reply-To: couponguru@gmail.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $message ="<html> <body> <center> <table> <tr> <td> <div style='border:0px dotted gray; width:450px; padding:15px; margin-left:30px; float:left; font-weight: normal; font-size: 12px; color: #01165c; font-family: Verdana; text-decoration: none;'> <p>Dear $data[1]</p> <p>Welcome to www.couponguru.com Newsletter community. <br> Every month we identify articles from a variety of publications that we think you may find interesting and that may not have come to your attention. Some of these may pertain directly to you, while others are more general or perhaps just offbeat. You can pick or choose what you would like to see and as always we welcome your feedback.</p> <p>Please have a look on Newsletter below<p> <br>Best Regards,<br>CouponGuru.com </div> </td> </tr> </table>"; mail($to, $subject, $message, $headers);
You need to add the content-type header along with your script which would tell the browser to display it as html. $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
thanks for reply from you. Yes i did that but didn't work even for this a simple one. Still it showing all html tags in gmail inbox. $to=$data[2]; $subject ="New Newsletter from couponguru.com"; $headers = 'From: ' . "\r\n" . 'Reply-To: ' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $message =" Dear subscriber, <h3 style='color: RED;'> This email confirms your purchase of a 30 day email support subscription. Please direct all requests to .</h3> Thank you, The Example.com support staff"; mail($to, $subject, $message, $headers);
update this way: $headers = 'From: couponguru@gmail.com' . "\r\n" . 'Reply-To: couponguru@gmail.com' . "\r\n" . "X-Mailer: PHP/" . phpversion()."\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; PHP: Also make the message complete HTML with <html><body> tags