我試圖通過PHP表單郵件將我的網站訪問者和電子郵件發送給我的工作室,然後發送一些說明和提示。 (我正在簡化一些表單字段)通過PHP表格發送HTML電子郵件
但是,HTML格式不能正常工作....我沒有正確地聲明MIME類型的字符集?
<?php
if (isset($_POST['submit'])) {
//if (empty ($_POST['name']) || empty($_POST['email']))
//{
//echo"<div class='error'>Error<br />You did not fill in a required field, please review your form and correct the missing information. <a class='close' href='#'>close</a></div>";
//}
$name = $_POST['name'];
$email = $_POST['email'];
$email2 = $_POST['email2'];
//A bunch of other fields are here
//Additional Headers
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
//$yoursite = "My Site";
//$youremail = $email;
$subject = "Website Form";
$message = "
$name would like you to contact them about your service.
Contact PH: $phone
Email: $email
Legal Guardian: $legal
//more stuff here
";
$subject2 = "Directions and Information";
$message2 = "<html><head></head><body>
$message2 .= "<h1>Directions</h1>
<p>text</p>
<p><a href='http://example.com/schedules'>Click here</a>
<h2>How Do I find your Photo Studio?</h2>
<h2>What do I have to bring with me?</h2>
</p>";
$message2 .= "</body></html>";
$email3 = "[email protected]";
$email4 = "[email protected]";
//This email sends their details to me from the visitor
mail($email3, $subject, $message, "From: $email");
//This email sends directions to the visitor from me
mail($email, $subject2, $message2, "From: $email4");
echo"<div class='thankyou'>Thank you for contacting us,<br /> we will respond as soon as we can.</div>";
}
?>
你甚至沒有使用`$ headers`變量。加上你有一個無與倫比的雙重報價'$ message2 =「
`我會建議使用一個優良的,免費的郵件類,例如PHP梅勒,斯威夫特梅勒。 – webbiedave 2011-01-11 22:25:07