简体   繁体   English

我的服务器名称显示为来自PHP联系人表单的提交者的回复电子邮件地址。

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

I'm not versed in PHP and had this form built for me. 我不精通PHP,并已为我构建了此表单。 It works 95% of the time, but sometimes the reply-to email will be johnsmith@hadrian.lunarpages.com 它在95%的时间内都有效,但是有时回复电子邮件为johnsmith@hadrian.lunarpages.com

I'm reading up a similar issue on this page , but not exactly sure what to change in my form... 我正在阅读此页面上的类似问题 ,但不确定是否可以更改表单中的内容...

<?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 {}  ?>

You're trying to send e-mail's to your self FROM the person whose entering this in, essentially attempting to spoof their email, and sometimes this will(should) get blocked. 您正在尝试从输入电子邮件的人向自己发送电子邮件,本质上是试图欺骗其电子邮件,有时(应该)将其阻止。 more can be read here - problem with php mail 'From' header 更多信息可以在这里阅读-php mail From头文件的问题

Change: 更改:

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

to

    $from = 'Admin@mysite.com';

    $headers .= "From: $from\r\n";
    $headers .= "Reply-To: $from \r\n";

and then edit that static $from variable. 然后编辑该静态$ from变量。 Then take the users email out of the BODY of the email you receive, and send them an email. 然后,将用户的电子邮件从收到的电子邮件的主体中取出,然后向他们发送电子邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM