PHP邮件表单不从主机发送

时间:2018-05-09 07:15:47

标签: php html phpmailer

我有一个php联系表单,已经与主机上传了。由于某种原因,表格没有发送? 。它在一个PHP文件中。没有错误,唯一的问题是它只是不发送。

这是PHP代码

<?php




    define("WEBMASTER_EMAIL", 'jonomarx20@gmailcom');
    $address = "jonomarx20@gmailcom";
    $address = "jonomarx20@gmailcom";
    if (!defined("PHP_EOL")) define("PHP_EOL", "\r\n");

    $error = false;
    $fields = array( 'name', 'email', 'phone', 'message' );

    foreach ( $fields as $field ) {
        if (empty($_POST[$field]) || trim($_POST[$field]) == '' )
            $error = true; 
    }


    if ( !$error ) { 


        $name = stripslashes($_POST['name']);
        $email = stripslashes($_POST['email']);
        $message = stripslashes($_POST['message']);
        $phone = stripslashes($_POST['phone']);


        $e_subject = 'You\'ve been contacted by ' . $name . '.';

        // Configuration option.
        // You can change this if you feel that you need to.
        // Developers, you may wish to add more fields to the form, in which case you must be sure to add them here.

        $e_body = "You have been contacted by: $name" . PHP_EOL . PHP_EOL;
        $e_reply = "E-mail: $email" . PHP_EOL . PHP_EOL;
        $e_content = "Message:\r\n$message" . PHP_EOL . PHP_EOL;
        $e_phone = "phone:\r\n$phone" . PHP_EOL . PHP_EOL;


        $msg = wordwrap( $e_body . $e_reply .$e_subject , 70 );

        $headers = "From: $email" . PHP_EOL;
        $headers .= "Reply-To: $email" . PHP_EOL;
        $headers .= "MIME-Version: 1.0" . PHP_EOL;
        $headers .= "Content-type: text/plain; charset=utf-8" . PHP_EOL;
        $headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;




        if(mail( $e_subject, $msg, $headers)) {

            // Email has sent successfully, echo a success page.

            echo 'Success';

        } else {

            echo 'ERROR!';

        }

    }




    ?>

这是HTML代码。

<!DOCTYPE html>
<!--[if IE 8 ]><html class="ie" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"><!--<![endif]-->
<head>
    <!-- Basic Page Needs -->
    <meta charset="UTF-8">
    <!--[if IE]><meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'><![endif]-->
    <title>Jono Marx - Contact Us</title>


    <!-- Mobile Specific Metas -->
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <!-- Boostrap style -->
    <link rel="stylesheet" type="text/css" href="stylesheet/bootstrap.min.css">

    <!-- Theme style -->
    <link rel="stylesheet" type="text/css" href="stylesheet/style.css">

    <!-- Colors -->
    <link rel="stylesheet" type="text/css" href="stylesheet/colors/color.css" id="colors">
    <!-- Reponsive -->
    <link rel="stylesheet" type="text/css" href="stylesheet/responsive.css">

    <!-- Animation Style -->
    <link rel="stylesheet" type="text/css" href="stylesheet/animate.css">

    <!-- Favicon and touch icons  -->
    <link href="icon/apple-touch-icon-48-precomposed.png" rel="apple-touch-icon-precomposed">
    <link href="icon/apple-touch-icon-32-precomposed.png" rel="apple-touch-icon-precomposed">
    <link href="icon/favicon.png" rel="shortcut icon">

</head>
    <body>
        <div class="boxed blog">
        <!-- Preloader -->
        <div id="loading-overlay">
            <div class="loader"></div>
        </div>
 <div class="top style1">





        <section class="flat-row flat-contact">
            <div class="container">
                <div class="row">
                    <div class="col-md-12">
                        <div class="flat-title style1 center">
                            <h2>Get in touch</h2>
                        </div>
                        <div class="flat-contact-form">
                            <form id="contactform"  method="POST" action="contact.php" class="form-info">
                                <div class="field-row">
                                    <div class="one-three">
                                        <p class="input-info"><input type="text" name="name" id="name" value="" placeholder="Your name *" required></p>
                                    </div>
                                    <div class="one-three">
                                        <p class="input-info"><input type="email" name="email" id="email" value="" placeholder="Email Address *" required></p>
                                    </div>
                                    <div class="one-three">
                                        <p class="input-info"><input type="text" name="phone" id="phone" value="" placeholder="Phone numbers *" required></p>
                                    </div>
                                </div>
                                <div class="input-text">
                                    <textarea id="message-contact" name="message" placeholder="Message *" required></textarea>
                                </div>
                                <div class="btn-submit">
                                    <button type="submit">SEND MESSAGE</button>
                                </div>
                            </form> <!-- /.flat-form-info -->
                        </div>
                    </div> <!-- /.col-md-12 -->
                </div><!-- /.row -->
            </div><!-- /.container -->
        </section><!-- /.flat-row-iconbox -->  

        <!-- map -->
 <?php include("includes/footer.php");?>


        <div class="button-go-top">
            <a href="#" title="" class="go-top">
                <i class="fa fa-chevron-up"></i>
            </a>
        </div>

        </div> <!-- /.boxed -->

    <!-- Javascript -->
    <script type="text/javascript" src="javascript/jquery.min.js"></script>
    <script type="text/javascript" src="javascript/tether.min.js"></script>
    <script type="text/javascript" src="javascript/bootstrap.min.js"></script>
    <script type="text/javascript" src="javascript/jquery.flexslider-min.js"></script>
    <script type="text/javascript" src="javascript/jquery.easing.js"></script>
    <script type="text/javascript" src="javascript/jquery-validate.js"></script>
    <script type="text/javascript" src="javascript/owl.carousel.js"></script>

    <script type="text/javascript" src="javascript/jquery.cookie.js"></script>
    <script type="text/javascript" src="javascript/gmap3.min.js"></script>
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAcNjdyQ_xJKXqTnbGIhw7jlls3idn9rZM"></script>
    <script type="text/javascript" src="javascript/waypoints.min.js"></script>
    <script type="text/javascript" src="javascript/main.js"></script>


    </body>
</html>

我不确定HTML代码是否存在问题,我做了vardump并且数组是空的,错误是否在于PHP代码?

全部谢谢,

0 个答案:

没有答案