gpt4 book ai didi

PHP 邮件 HTML 格式不起作用

转载 作者:可可西里 更新时间:2023-10-31 22:43:43 24 4
gpt4 key购买 nike

我编写了一个代码来使用 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);

但是这个输出看起来像这样:

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

显示所有没有格式化的html代码,谁能帮我,我找不到错误

最佳答案

你在这里覆盖了$header变量

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

应该是

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

关于PHP 邮件 HTML 格式不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21179111/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com