<?php
session_start();
$returnURL = $_POST["pageURL"].'#confirmation';
if (empty($_POST["phone"]) || empty($_POST["email"]) || empty($_POST["name"]) || empty($_POST["address"]) ) {
$_SESSION["confirmation"] = "empty";
header('Location: '.$returnURL);
exit;
} else {
$to = 'email@email.com';
$headers = 'From: ' . $_POST["name"] . '<' . $_POST["email"] . '>';
$subject = 'Email from your landing page';
$message = (
"You have received a inquiry from your landing page! \n\n Name: " . $_POST["name"] . "
\n Email: " . $_POST["email"] . "
\n Phone Number: " . $_POST["phone"] . "
\n Mailing Address: " . $_POST["address"] . "
\n Message: " . $_POST["message"]
);
mail($to, $subject, $message, $headers);
$_SESSION["confirmation"] = 'yes';
header('Location: '.$returnURL);
exit;
}
?>
答案 0 :(得分:0)
请参阅mail
函数的文档,它会返回一个值。检查并报告回来。调试时也禁用重定向:
$result = mail($to, $subject, $message, $headers);
var_dump($result);
exit;
答案 1 :(得分:0)
标题可能非常挑剔。尝试在From。
的末尾添加新行$headers = 'From: ' . $_POST["name"] . '<' . $_POST["email"] . ">\r\n";