0
<?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;
    }
?>
4

2 回答 2

0

请参阅mail函数的文档,它返回一个值。检查并报告回来。调试时还要禁用重定向:

$result = mail($to, $subject, $message, $headers);
var_dump($result);
exit;
于 2012-08-16T19:42:48.323 回答
0

标题可能非常挑剔。尝试在 From 末尾添加新行。

$headers = 'From: ' . $_POST["name"] . '<' . $_POST["email"] . ">\r\n";
于 2012-08-16T20:10:14.240 回答