PHP Mail仅发送给发件人的输入邮件

时间:2016-09-12 21:04:08

标签: php html email

所以,我在我的网站上发送了一个发送邮件的PHP脚本:

<?php
    $name= $_REQUEST['name'];
    $email = $_REQUEST['email'];
    $phone = $_REQUEST['phone'];
    $city = $_REQUEST['city'];
    $message = $_REQUEST['message'];
    $destination = "my@mail.com";
    $subject = "Contact Message";

    $header = "From: $email\r\n";
    $header .= "Return-Path: $email\r\n";

    $message2 = "Name: $name\r\n";
    $message2 .="Phone: $phone\r\n";
    $message2 .= "Email: $email\r\n";
    $message2 .= "City: $city\r\n";
    $message2 .= "Message: $message";

    mail($destination, $subject, $message2, $header);
    header('Location: thanks.php');
?>

,HTML是:

<form method="post" action="mail.php">
    <p>Name</p>
    <input type="text" name="name" required>

    <p>Phone</p>
    <input type="tel" name="phone" required>

    <p>Email</p>
    <input type="email" name="email" required>

    <p>City</p>
    <input type="text" name="city" required>

    <p>Message</p>
    <textarea name="message" required></textarea>

    <button type="submit">SEND</button>

    <div class="clear"></div>
</form>

但是,如果邮件不是my@mail.com(与我的固定目的地相同),邮件将不会被发送。我不知道为什么会这样,我根本不知道。我仔细检查了每个单词,看看是否有错误,但没有。我已在多个页面中使用此脚本,并且每次都有效。

0 个答案:

没有答案