如果我從郵件功能中刪除$頭功能它的工作,它發送$郵件包含在郵件中的所有HTML代碼而不是顯示錶,但是當我在郵件功能中包含$頭時,它不發送郵件它甚至沒有顯示任何錯誤。我的code.im正在web服務器上工作。PHP的郵件功能不工作
<?php
//Deal with the email
if(isset($_POST['submit']))
{
$to = '[email protected]';
$title = 'New Enquiry || example.com';
$subject = $_POST['subject'];
$message = $_POST['message'];
$name = $_POST['name'];
$email = $_POST['email'];
}
$headers .= "From: " . strip_tags($email) . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$msg = '<html><head><body><b>'.$title.'</b>
<br>
<table bgcolor=#CCCCCC>
<tr>
<td> Subject : </td>
<td> '.$subject.'</td></tr>'
.'<tr> <td> Contact person: </td><td>'.$name.'</td></tr>'
.'<tr> <td> E-mail:</td><td> '.$email.'</td></tr>'
.'<tr><td> Message : </td><td>'.$message.' </td></tr></table></body></head></html>';
mail($to, $title, $subject, $msg, $headers);
header("refresh:1;url=contact-us-ok.html");
?>
@DanyCaissy那麼爲什麼沒有'$頭'呢? – Barmar
您的HTML嵌套錯誤。你不能在'
'內部有''。 – Barmar感謝指出它的人。我不知道爲什麼它的工作沒有$頭,但我已經讀過$頭是可選的。 – 8bitrebellion