我正在遵循教程http://css-tricks.com/sending-nice-html-email-with-php/ 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 格式发送
From:
$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, '[email protected] /cdn-cgi/l/email-protection', $pr_email, $subject, $message); $SMTPChat = $SMTPMail->SendMail();
你从来没有发送过$headers
var 因此,电子邮件没有标头,因此另一端的邮件客户端不会读取 MIME 类型。
我不明白SMTPClient
类并从教程中判断,我建议您最好不要使用它,因为它直接打开到 SMTP 服务器的套接字。此外,这个类实际上并不支持自定义标头,这很糟糕。mail()
将使用您的默认 SMTP 服务器。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)