在php邮件上获取302$ toEmail,$ emailSubject,$ body,$ headers;

问题描述

我有一个托管实例,仅用于测试2个文件 index.html和contact.php

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple contact Form</title>
</head>

<body>
    <form action="contact2.php" method="post">
        <input name="firstName" placeholder="firstName" type="text" size="30" />
        <input name="lastName" placeholder="lastName" type="text" size="30" />
        <input name="email" placeholder="email" type="text" size="30" />
        <input name="submit" type="submit" value="Send This">
    </form>
</body>
</html>

php代码

<?php

    $firstName = $_POST['firstName'];
    $lastName = $_POST['lastName'];
    $email = $_POST['email'];
    $toEmail = '[email protected]';
    $emailSubject = "Contact Form:";
    $headers = ['From' => $email,'Reply-To' => $email];
    $body = "Name: $firstName $lastName";
    mail($toEmail,$emailSubject,$body,$headers);
    header("Location: index.html"); 
?>

结果:未发送(或接收)邮件,并且状态为302重定向(不确定原因)。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)