gpt4 book ai didi

PHP 邮件 html 格式不起作用

转载 作者:可可西里 更新时间:2023-11-01 12:40:33 25 4
gpt4 key购买 nike

使用 php 并使用此代码我收到了纯文本电子邮件,我是否遗漏了什么?因为我需要发送格式化的电子邮件,其中可能包含例如链接。

$to = "receiver@test.com";
$subject = "Password Recovery";

$body = '
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = "From: info@test.net\r\n"."X-Mailer: php";
if (mail($to, $subject, $body, $headers))
echo "Password recovery instructions been sent to your email<br>";

最佳答案

您已重新设置 header :

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = "From: info@test.net\r\n"."X-Mailer: php";

你在最后一行漏掉了一个点,它覆盖了前两行:

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: info@test.net\r\n"."X-Mailer: php";

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

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