...">

PHP HTML formatting not working

I wrote code to send PHP mail in 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 = 'xxx@xxxxxxxx.com'; 
    $mail_subject = 'Booking';
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers = 'From: <xxx@xxxxxx.com>';        
    mail($mail_to, $mail_subject, $email_message, $headers);

but this conclusion is as follows:

<html>
<body>
<table>
<tr>
<td colspan="2"><div style="color: #3300FF; font-size: 18px;">

displays all html code without formatting, can anyone help me, I cannot find the error

+4
source share
3 answers

You rewrite the variable $headerhere

$headers = "From: <xxx@xxxxxx.com>";   

It should be

$headers .= "From: <xxx@xxxxxx.com>";   // Add the concatenate operator 
+5
source

the last line of the title, I think your title, which you forgot, concatenate

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = 'From: <xxx@xxxxxx.com>'; 
+1
source

@shankar , , , .

html-

0

All Articles