PHP邮件表单未从主机发送

PHP邮件表单未从主机发送,php,html,phpmailer,Php,Html,Phpmailer,我有一个php联系人表单,它已经上传到主机上了。由于某种原因,表单未发送。它位于一个PHP文件中。并没有错误,唯一的问题是它并没有发送 下面是PHP代码 <?php define("WEBMASTER_EMAIL", 'jonomarx20@gmailcom'); $address = "jonomarx20@gmailcom"; $address = "jonomarx20@gmailcom"; if (!defined("PHP_EOL")) d

我有一个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代码中


谢谢大家,

您试着调试了什么?如果您不确定是否实际收到了
邮件
呼叫,请在这里和那里添加
vardump
以查看发生了什么事情hi@NicoHaase,我在哪里执行vardump?我把它放在foreach后面,我是新来PHP的。当我把它放在foreach后面时,它是空的。$address就是这个问题吗?你可以把它放在任何你想看到调试输出的地方,你可以使用任何你想检查的变量。如果你是PHP新手,最好的方法就是学习使用composer使用库。使用
mail()
发送电子邮件极为困难,这意味着您知道如何配置邮件服务器,并且在出现问题时(如您所发现的)很少提供反馈。你用-标记了这个问题,我建议你试着用它来代替。@Synchro,我是通过我的主机来做的,我不需要配置邮件服务器,现在发生的是vardump post变量是空的,因此表单中的详细信息无法通过