Reputation: 2935
I wrote a code to send PHP mail using HTML format.
$email_message = '
<html>
<body>
<table>
<tr>
<td colspan="2"><div style="color: #3300FF; font-size: 18px;">text</div></tr></table></body></html>';
$mail_to = '[email protected]';
$mail_subject = 'Booking';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = 'From: <[email protected]>';
mail($mail_to, $mail_subject, $email_message, $headers);
but this output look like this:
<html>
<body>
<table>
<tr>
<td colspan="2"><div style="color: #3300FF; font-size: 18px;">
display all html code without formatting, could any one help me, I can't find the error
Upvotes: 4
Views: 2459
Reputation: 68526
You are overwriting $header
variable here
$headers = "From: <[email protected]>";
That should be
$headers .= "From: <[email protected]>"; // Add the concatenate operator
Upvotes: 5
Reputation: 15336
Although @shankar pointed out, but I think thats not the issue because first variable should be initialise in order to concatenate it.
Here is the link for proper html email
Upvotes: 0
Reputation: 11
the last line of the header i think your header you forgot to concatenate
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = 'From: <[email protected]>';
Upvotes: 1