我的服务器'的名字显示为提交者'的回复电子邮件地址从PHP联系表单


My server's name shows up as submitter's Reply-to email address from PHP contact Form

我不精通PHP,并为我构建了这个表单。它在95%的情况下有效,但有时回复电子邮件将是johnsmith@hadrian.lunarpages.com

我在这个页面上读到一个类似的问题,但不确定在我的表单中应该改变什么…

<?php
if (isset($_REQUEST['btnSubmit-group'])) {
    $date = $_REQUEST['date'];
    $time = $_REQUEST['time'];
    $count = $_REQUEST['count'];
    $name = $_REQUEST['name'];
    $organization = $_REQUEST['organization'];
    $email = $_REQUEST['email'];
    $grouptype = $_REQUEST['grouptype'];   
    $phone = $_REQUEST['phone'];
    $upgrademus = $_REQUEST['upgrademus'];
    $upgradeowo = $_REQUEST['upgradeowo'];
    $comments = $_REQUEST['comments'];
    $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
    if ($count == "" || $name == "" || $email == "" || $phone == "") {
        echo "All fields are required, please fill out again. ";
    } else {
        $to = 'info@example.com';
        $subject = "Group Tour Inquiry from $name ($date, $count people)";
        $from = $to;
        $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
        $body = nl2br("Private Tour:<br>" .
                "<b>Name:</b>   $name'r'n" .
                "<b>Email:</b>  $email 'r'n" .
                "<b>Phone:</b>  $phone 'r'n" .
                "<b>Organization:</b>     $organization'r'n" .
                "<b>Date:</b>     $date'r'n" .
                "<b>Time:</b>     $Time'r'n" .
                "<b>Count:</b>     $count'r'n" .
                "<b>Include:</b>     $upgrademus'r'n" . 
                "<b>Include:</b>     $upgradeowo'r'n" .
                "<b>Comments:</b>     $comments'r'n" .
                "");
// To send HTML mail, the Content-type header must be set
        $headers = 'MIME-Version: 1.0' . "'r'n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "'r'n";
        $headers .= "From: $name<$email> 'r'n";
        $headers .= "Reply-To: $email 'r'n";
        if (mail($to, $subject, $body, $headers)) {
            echo "<div class='"thankyou'"></div><meta http-equiv='refresh' content='0;url=http://www.example.com/private-group-tours'>";
        }
    }
} else {}  ?>

你试图从输入这个的人那里发送电子邮件给你自己,本质上是试图欺骗他们的电子邮件,有时这将(应该)被阻止。php邮件'From'头

改变:

    $headers .= "From: $name<$email> 'r'n";
    $headers .= "Reply-To: $email 'r'n";

    $from = 'Admin@mysite.com';
    $headers .= "From: $from'r'n";
    $headers .= "Reply-To: $from 'r'n";

,然后编辑静态$from变量。然后将用户的电子邮件从您收到的电子邮件的正文中取出,并向他们发送电子邮件。

相关文章: