Reputation: 93
I am sending mail by php and in the message part, my code is like:
$email_body = "<style type=\"text/css\">
p {padding:0 !important; margin:0 !important;}
td {padding:0 10px !important; margin:0 !important; font-family:Verdana, Geneva, sans-serif;}
td table td {padding:0 !important;}
</style>
<table align=\"center\" border=\"0\" cellpadding=\"10\" cellspacing=\"0\" style=\"border-collapse:collapse; border:1px solid #565656; font-family:Verdana, Geneva, sans-serif; width:800px; margin-top:0px; color:#565656;font-weight:normal;font-size:12px; text-align:justify; line-height:1.5em\">
<tbody>
<tr>
<td style=\"border-collapse:collapse; padding-top:10px !important;\">
message
</td>
</tr>
</tbody>
</table>";
But in my mail I am getting the full html code whatever it is written for $email_body instead of tabular format. How to do that? Thanks.
Upvotes: 1
Views: 64
Reputation: 6482
You need to set the correct headers:
$to = '[email protected]';
$subject = 'foobar';
$message = '...'; // the html
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);
Have a look at the manual: http://php.net/manual/en/function.mail.php
You also need a complete html doc, that is:
html
head
title
style
body
table
And a tip, if you send html mails, don't use the style tag. I often use this premailer: http://premailer.dialect.ca/
Upvotes: 1