我正在尝试使用 php 发送 HTML 电子邮件。我的代码如下:
$to = "test@test.com";
$from = "$senderEmail";
$subject = "Quote Request";
$message = <<<EOF
<html>
<body bgcolor="#FFFFFF">
<b>Firstname</b> = $senderFirstname<br /><br />
<b>Lastname</b> = $senderLastname<br /><br />
<b>Title</b> = $senderTitle<br /><br />
<b>Company</b> = $senderCompany<br /><br />
<b>Street</b> = $senderStreet<br /><br />
<b>City</b> = $senderCity<br /><br />
<b>State</b> = $senderState<br /><br />
<b>Zip</b> = $senderZip<br /><br />
<b>Phone</b> = $senderPhone<br /><br />
<b>Fax</b> = $senderFax<br /><br />
<b>Email</b> = <a href="mailto:$senderEmail">$senderEmail</a><br /><br />
<b>Installtype</b> = $sendeInstalltype<br /><br />
<b>Facilitytype</b> = $senderFacilitytype<br /><br />
<b>Message</b> = $senderMessage<br />
</body>
</html>
EOF;
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
mail($to, $subject, $message, $headers);
发送邮件时,它会以全文形式出现,第一行是“Content-type: text/html”。我之前多次使用过相同的脚本,没有问题。它所在的服务器正在使用 php 5.1.6 这可能是问题吗?