-3

私は以下のフォームを持っており、差出人メールアドレスを別のものに変更する方法を理解しようとして頭を悩ませています。

現在、phpサーバーを使用しており、使用されている電子メールの自動返信は自動返信を送信しており、大きな混乱を引き起こしています。どんな助けでも本当に感謝しています。

<?php



if(isset($_POST['submit'])) {



    //create an empty errors array

    $errors = array();

    //our form has been submitted

    if($_POST['name'] == "") {

        //the name field is empty

        $errors[] = "The name field is empty";

    }

    if($_POST['email'] == "") {

        //the email field is empty

        $errors[] = "The email field is empty";

    }

    if($_POST['comment'] == "") {

        //the comment field is empty

        $errors[] = "The comment field is empty";

    }




    if($_POST['phone'] == "") {

        //the comment field is empty

        $errors[] = "The phone field is empty";

    }


            if($_POST['passengers'] == "") {

        //the comment field is empty

        $errors[] = "The passengers field is empty";

    }



    if($_POST['destination'] == "") {

        //the comment field is empty

        $errors[] = "The destination field is empty";

    }

    if(!stripos($_POST['email'], '@')) {

        $errors[] = "The email address was not valid";

    }

    if(count($errors) == 0) {

        $sendto = "inquiry@maximtours.net";

        $title = "Contact Form";

        $email = $_POST['email'];

        $message = "Name: ".$_POST['name']. "\n".
            "Mail: ".$_POST['email']. "\n".
            "Date of Travel: ".$_POST['month'].". " .$_POST['day'].", " .$_POST['year'] ."\n".
            "Phone No: ".$_POST['phone']. "\n".
            "Number of Passengers: ".$_POST['passengers']. "\n".
            "Traveling From: ".$_POST['city']. "\n".
            "Destination: ".$_POST['destination']. "\n".
            "Comment: ".$_POST['comment']. "\n";


        $headers = "From: " . $_POST['email'] . "\r\n" .
            "Reply-To: " . $_POST['email'] . "\r\n" .
            "X-Mailer: PHP/" . phpversion();


           if(mail($sendto, $title, $message, $email, 'inquiry@maximtours.net'.$email)) {

                $success = true;

            } else {

                $success = false;

            }



    } 
}

?>
<?php

if(isset($_POST['submit'])) {

    if($success == true && count($errors) == 0) {

        echo "<h2>Thanks for getting in touch!</h2>";


    }

    if(count($errors) == 0 && $success == false && isset($_POST['submit'])) {

        echo '<h2>There was a problem with our form. Please email us directly via inquiry@maximtours.net.</h2>';

    }



    if(isset($_POST['submit']) && $success == false && count($errors) > 0) {

        echo "<ul>";

        foreach($errors as $e) {

            echo "<li>$e</li>";

        }

        echo "</ul>";

    }

}

?>
4

2 に答える 2

0

i think you need some change here

mail($sendto, $title, $message, $email, 'inquiry@maximtours.net'.$email)

change this to

mail($sendto, $title, $message, $headers);

and whatever from address you need you can set in $headers.

于 2013-09-19T19:28:57.787 に答える