[英]PHP mail HTML formatting not working
I wrote a code to send PHP mail using HTML format. 我写了一个代码来使用HTML格式发送PHP邮件。
$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 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 显示所有没有格式化的HTML代码,任何人都可以帮助我,我找不到错误
You are overwriting $header
variable here 你在这里覆盖了
$header
变量
$headers = "From: <xxx@xxxxxx.com>";
That should be 那应该是
$headers .= "From: <xxx@xxxxxx.com>"; // Add the concatenate operator
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: <xxx@xxxxxx.com>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.