我有一个能够轻松输出消息($ message)的联系表单,但我添加了其他变量,例如。日期,派对等。这些看似正确,但我尝试添加HTML代码,使输出更结构化,但它只是打印HTML代码!
如果可以,请提供帮助,请参阅下面的代码。需要工作的线是:
mail( "theresa.pert@me.com", "VoH Online Enquiry",
"Name: $name.</p>, Telephone Number: $telephone, Tour Date: $date, No in Party: $party, Message: $message","From: $email");
<?php
$email = $_REQUEST['email'] ;
$name = $_REQUEST['name'] ;
$telephone = $_REQUEST['telephone'] ;
$date = $_REQUEST['date'] ;
$party = $_REQUEST['party'] ;
$message = $_REQUEST['message'] ;
if (!isset($_REQUEST['email'])) {
header( "Location: ../contact.shtml" );
}
elseif (empty($email) || empty($message)) {
header( "Location: ../contact-error.shtml" );
}
else {
mail( "theresa.pert@me.com", "VoH Online Enquiry",
"Name: <p>$name</p> <p>Telephone Number: $telephone</p> <p>Tour Date: $date</p> <p>No in Party: $party</p><p>Message: $message</p>","From: $email");
header( "Location: ../contact-thankyou.shtml" );
}
?>
答案 0 :(得分:1)
您需要在邮件功能中指定标题:
$headers = "Reply-To: .... <mail@blabla.blabla>\r\n";
$headers .= "Return-Path: .... <mail@blabla.blabla>\r\n";
$headers .= "From: .... <mail@blabla.blabla>\r\n";
$headers .= "Organization: .... <mail@blabla.blabla>\r\n";
$headers .= "Content-Type: text/html\r\n";
mail($email, $object, $text, $headers);
查看Mail文档