我有PHP腳本,工作正常。發送郵件時,除了郵件外,一切正常。下面是我在電子郵件中得到: 新郵件來自:PHP聯繫表格消息不顯示在電子郵件
Name: asdf
Phone: 9879879879
Email: [email protected]
Project Location: asdf
Message:
正如你所看到的,「消息:」沒有顯示什麼形式輸入。這裏是代碼: Cotnact表格 font-family:Verdana,sans-serif; font-size:12px; }
聯繫
變量/ //您的電子郵件地址類型接收郵件 $到= 「 [email protected]」;//If you wish to show a logo in the mail, paste the URL here.
//For example: http://mywebsite.com/mylogo.png
//Remember http://
$logo_url = "http://arniesremodeling.com/Logo1.png";
/*VARIABLES END*/
if(isset($_POST['name'])){
$name = preg_replace('/[^A-Za-z0-9\-]/','', $_POST['name']);
$phone = preg_replace('/[^0-9]/',"", $_POST['phone']);
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$location = preg_replace('/[^ A-Za-z0-9,\-]/',"", $_POST['name']);
$message = preg_replace('/[^ A-Za-z0-9,.?\-]/',"", $_POST['message']);
$ip_address = $_SERVER['REMOTE_ADDR'];
if($name == "" or $phone == "" or $location == "" or $message == ""){
echo'One or more fields has not been filled out.<br>
Please go back and try again.';
}
elseif(strlen($phone) != 10){
echo'Invalid Phone Number.<br>
Please enter a valid phone number.';
}
elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)){
echo'The email address could not be validated.<br>
Please go back and verify your email address.';
}
else{//All checks passed
if(isset($logo_url) and strlen($logo_url) > 3){
$logo = '<img src="'.$logo_url.'" alt="" style="border:none;"><br><br>';
}
else{
$logo = "";
}
$headers = "From: Arnie's Remodeling";
$headers .= "Reply-To: $email\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
$message = '<html><head><style>body {font-family: Verdana; font-size: 12px;} </style></head><body>';
$message .= "$logo
New Mail from:<br><br>
Name: $name <br>
Phone: $phone <br>
Email: $email <br>
IP: $ip_address <br><br>
Project Location: $location <br>
Message:<br>
".nl2br($message)."
</body></html>";
$sendMail = mail($to, $location, $message, $headers);
if($sendMail){
echo'Thank You, the mail has been successfully sent!<br><br>';
}
else{
echo'An error occurred and the mail could not be sent.<br>
Please try again later.';
}
}
}
else{
header("location:contact.html");
}
?>
</body>
</html>
you ar在定義$標題後覆蓋$ message變量 – guri
哦,哇,我不敢相信我沒有注意到,大聲笑非常感謝你! :) – ironspeed12