我面临一个问题,当我使用 发送邮件时mail()
,它会在邮件中发送 HTML 代码。这是我的代码:
<?php
$message = "<table width='100%' border='0' cellspacing='0' cellpadding='3'>
<tr>
<td colspan=2>Dear ".$_POST['fname']." ".$_POST['lname'].",</td>
</tr>
<tr>
<td colspan=2>Thank you for contacting us.We will get back to you in next 48 hrs.Your Contacts Details are as follows:</td>
</tr>
<tr>
<td width='28%' >Title</td>
<td width='72%'>".$_POST['title']."</td>
</tr>
<tr>
<td>Email</td>
<td>".$_POST['email']."</td>
</tr>
<tr>
<td>Your Message</td>
<td>".$_POST['message']."</td>
</tr>
<tr>
<td>How did you hear about us? </td>
<td>".$checkBox."</td>
</tr>
</table>
";
$subject = "ContactUs";
$headers .= "From: ".$from_mail." \r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
mail($_POST["coach"], $subject, $message, $headers);
?>
我在电子邮件中收到的输出如下所示:
<table width='100%' border='0' cellspacing='0' cellpadding='3'>
<tr>
<td colspan=2>Dear Test User,</td>
</tr>
<tr>
<td colspan=2>Thank you for contacting us.Your Contacts Details are as follows:</td>
</tr>
<tr>
<td width='28%' >Title</td>
<td width='72%'>Mr.</td>
</tr>
<tr>
<td>Email</td>
<td>test@example.com</td>
</tr>
<tr>
<td>Your Message</td>
<td>Test Message</td>
</tr>
<tr>
<td>How did you hear about us? </td>
<td>www.example.com</td>
</tr>
</table>
我不知道为什么会这样。任何建议将不胜感激。