我试图制作自己的定制联系表格。测试和改进过程中,我发现电子邮件没有以HTML格式呈现。我不确定为什么会出现这种情况,但我发现我必须做错了什么,因为我的电子邮件服务提供商从其他来源接收到的电子邮件是以HTML格式呈现的。我认为消息正文变量内的HTML代码也是正确的,所以问题可能与标题变量或设置方式有关。
备注:与某些人建议的不同,使用样式标签并非我的问题,因为我没有使用Gmail(它不接受它们),而是Outlook(它可以接受它们)。
备注:与某些人建议的不同,使用样式标签并非我的问题,因为我没有使用Gmail(它不接受它们),而是Outlook(它可以接受它们)。
if ($_POST['Submit']) {
if (empty($_POST['Phone'])) {
$content = "<html>
<head></head>
<body>
<div class='boldtext'>From:</div>
$name
<br/>
<div class='boldtext'>E-mail:</div>
$email
<br/><br/>
$message
<style>
.boldtext {
font-weight: bold;
}
</style>
</body>
</html>";
}
Above is part of my PHP code for the form action. The remaining part is some regex validations for each input and echos as response to those. The submissions are sent to an Outlook email address, which I know is compatible with the style tag in the head or body. What am I doing wrong?
Sample of email literally received by client:
<html>
<head></head>
<body>
<div class='boldtext'>From:</div>
John Doe
<br/>
<div class='boldtext'>E-mail:</div>
email@email.com
<br/><br/>
This is a message.
<style>
.boldtext {
font-weight: bold;
}
</style>
</body>
</html>