gpt4 book ai didi

PHP:Html 以 html 格式发送电子邮件

转载 作者:行者123 更新时间:2023-12-04 05:35:16 26 4
gpt4 key购买 nike

我正在学习教程 http://css-tricks.com/sending-nice-html-email-with-php/以html格式发送邮件。

我的字符串看起来像

$message = '<html><body>';
$message .= '<img src="http://css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Change Request" />';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>Dear:</strong> </td><td>" . strip_tags($part_name). "</td></tr>";
$message .= "<tr><td><strong>.$user_name.has fixed an appointment with you on :</strong> </td><td>" . strip_tags($time). "</td></tr>";
$message .= "<tr><td><strong>In:</strong> </td><td>" . strip_tags($meeting_name) . "</td></tr>";
$message .= "<tr><td><strong>Please click on:</strong> </td><td><a href=" . strip_tags($approve_url). "</a> To approve</td></tr>";
$message .= "</table>";
$message .= "</body></html>";

// CHANGE THE BELOW VARIABLES TO YOUR NEEDS

$subject = 'Appointment Request ';

$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

但是收到的邮件不是 html 格式,它看起来像
<html>
<body>
<img src="http://css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Change Request" />
<table rules="all" style="border-color: #666;" cellpadding="10">
<tr style='background: #eee;'>
<td>
<strong>Dear:</strong>
</td>
<td>Depu</td>
</tr>
<tr>
<td>
<strong>.pandit.has fixed an appointment with you on :</strong>
</td>
<td>
</td>
</tr>
<tr>
<td>
<strong>In:</strong>
</td>
<td>anyp</td>
</tr>
<tr>
<td>
<strong>Please click on:</strong>
</td>
<td>
<a href=http://192.168.0.178/UI/user/approvemeeting.php?meetingid=REG_939300945&key=3107</a> To approve
</td>
</tr>
</table>
</body>
</html>

请告诉我我做错了什么,为什么邮件没有以 html 格式发送

最佳答案

请改用 PHPMailer。

它允许您发送 SMTP 和普通电子邮件(PHP 的 mail() 函数或显式所有 SMTP 参数),最重要的是它允许您指定 HTML 消息、纯文本替代消息(但不要指定它,否则某些客户端不会显示 HTML 文件,例如血腥的 Lotus Notes)。

它允许您指定标题、mime 等...

http://phpmailer.worxware.com/

关于PHP:Html 以 html 格式发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12035742/

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