PHP电子邮件表单不发送电子邮件

PHP电子邮件表单不发送电子邮件,php,html,forms,email,Php,Html,Forms,Email,有人能帮我弄清楚为什么这个电子邮件表单不会发送电子邮件吗?我查过了,他们说服务器上的电子邮件功能已经打开,其他网站也可以发送电子邮件。表单正在提取数据。。。它只是不会发送电子邮件。我觉得很明显,这会导致邮件无法发送,而我就是看不到 <?php require 'topInclude.php'; ?> <div id="contentwrapper"> <div id="waiverContent"> <div id="dvdConten

有人能帮我弄清楚为什么这个电子邮件表单不会发送电子邮件吗?我查过了,他们说服务器上的电子邮件功能已经打开,其他网站也可以发送电子邮件。表单正在提取数据。。。它只是不会发送电子邮件。我觉得很明显,这会导致邮件无法发送,而我就是看不到

<?php 
    require 'topInclude.php';
?>
<div id="contentwrapper">
<div id="waiverContent">
    <div id="dvdContentRight">
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            var defaultMessage = "Please provide a brief description of how you plan to adapt the messaging and/or graphic design.";
            $("#myTextArea").focus(function(){
                if( $(this).val() == defaultMessage){
                    $(this).val("");
                }
            }).blur(function(){
                if( $(this).val() == "" ){
                    $(this).val(defaultMessage);
                }
            }).val(defaultMessage);
        });
    </script>

<?php       
if (isset($_POST['submit'])) {

$errors = array(); // Initialize the errors array

if (empty($_POST['company_name'])) {
     $errors[] = 'Please enter your first name.';
} else {
      $Cn = filter_var($_POST['company_name'], FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW, FILTER_FLAG_STRIP_HIGH);
}

if (empty($_POST['contact_name'])) {
    $errors[] = 'Please enter your name.';
} else {
    $ln = filter_var($_POST['contact_name'], FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW, FILTER_FLAG_STRIP_HIGH);
}

if (empty($_POST['address'])) {
    $errors[] = 'Please enter your work address.';
} else {
    $add = filter_var($_POST['address'], FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW, FILTER_FLAG_STRIP_HIGH);
}

if (empty($_POST['email'])) {
    $errors[] = 'Please enter your email address.';
} else {
    $e = filter_var($_POST['email'], FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW, FILTER_FLAG_STRIP_HIGH);
}

if (empty($_POST['comments']) || ($_POST['comments'] == 'Please provide a brief description of how you plan to adapt the messaging and/or graphic design.')) {
    $errors[] = 'Please provide a brief description of how you plan to adapt the messaging and/or graphic design.';
} else {
    $co = filter_var($_POST['comments'], FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW, FILTER_FLAG_STRIP_HIGH);
}

if (!empty($_POST['phone'])) {
    $p = $_POST['phone'];
} else {
    $p = '';
}

if (empty($_POST['checkbox'])) {
    $errors[] = 'You must agree to the Permission To Use / Reproduce conditions.';
} else {
    $cb = $_POST['checkbox'];
}

    if (empty($errors)) { 
        $body = "The information sent is as follows:\n\n Company Name: $Cn \n Contact Name: $ln \n Work Address: $add \n Phone: $p \n Email: $e \n I agree to terms: $cb \n\n Comments: $co"; 
        mail ('xxxxxxxx@gmail.com', 'W.E. Can Quit DVD Request', $body, 'From: '.$e);

        echo '<div id="email"><div id="emailSent">
                <h1>Thank you!</h1>
                <p>Your request has been sent.</p>
              </div>';
        echo '<div id="emailSentImg"><img src="images/emailSent.jpg" /></div></div>';

    } else { //Report any collected errors in the errors array.
        echo '<div id="emailNotSent">
            <h1>Error!</h1><br />
            <p>The following error(s) occurred:<br />';
            foreach ($errors as $msg) {
                echo " - $msg<br />\n";
            }
        echo '</p><br /><p>Please use the \'back\' button in your browser and try again.</p>
              </div>';

    } // Ends the empty errors array if.

    } else { // Form has not been submitted; display the form.
    $errors = NULL; 
?>

$(文档).ready(函数(){
var defaultMessage=“请简要说明您计划如何调整消息和/或图形设计。”;
$(“#myTextArea”).focus(函数(){
if($(this).val()==defaultMessage){
$(此).val(“”);
}
}).blur(函数(){
if($(this).val()==“”){
$(this).val(defaultMessage);
}
}).val(默认消息);
});
这是电子邮件表格:

<h2>Order Your DVD</h2>
        <div id="dvdForm">
            <form name="form" id="form" method="POST" action="<?php echo $PHP_SELF;?>">
            <table width="550px">
                <tr>
                    <td valign="top">
                        <label for="company_name" class="formText">Company Name:</label>
                    </td>
                    <td valign="top">
                        <input  type="text" name="company_name" maxlength="50" size="45" value="<?php if (isset($_POST['company_name'])) echo $_POST['company_name']; ?>">
                    </td>
                </tr>
                <tr>
                    <td valign="top">
                        <label for="contact_name" class="formText">Contact Name:</label>
                    </td>
                    <td valign="top">
                        <input  type="text" name="contact_name" maxlength="50" size="45" value="<?php if (isset($_POST['contact_name'])) echo $_POST['contact_name']; ?>">
                    </td>
                </tr>
                <tr>
                    <td valign="top">
                        <label for="address" class="formText">Work Address:</label>
                    </td>
                    <td valign="top">
                        <input  type="text" name="address" maxlength="50" size="45" value="<?php if (isset($_POST['address'])) echo $_POST['address']; ?>">
                    </td>
                </tr>
                <tr>
                    <td valign="top">
                        <label for="phone" class="formText">Phone Number:</label>
                    </td>
                    <td valign="top">
                        <input  type="text" name="phone" maxlength="12" size="45" value="<?php if (isset($_POST['phone'])) echo $_POST['phone']; ?>">
                    </td>
                </tr>
                <tr>
                    <td valign="top">
                        <label for="email" class="formText">Email Address:</label>
                    </td>
                    <td valign="top">
                        <input  type="text" name="email" maxlength="80" size="45" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>">
                    </td>
                </tr>
                <tr>
                    <td valign="top" colspan="2">
                        <textarea id="myTextArea" rows="4" cols="37" name="comments" value="<?php if (isset($_POST['comments'])) echo $_POST['comments']; ?>"></textarea>
                    </td>
                </tr>
                <tr>
                    <td valign="top">
                        <label for="checkbox">
                        I agree to all of the terms set 
                        out in the <span class="italics">Permission To <br />
                        Use / Reproduce</span> conditions on 
                        the left side of this page.</label>
                    </td>
                    <td valign="top">
                        <input  type="checkbox" name="checkbox" value="Agreed">
                    </td>
                </tr>
                <tr>
                    <td>
                    </td>
                    <td>
                        <input type="submit" value="Submit" name="submit">
                    </td>
                </tr>
            </table>
            </form>
        </div>
    <?php } ?>
    </div>                      
</div>
</div>
<?php
    require 'bottomInclude.php';
?>
订购您的DVD
mail()可能是一个很难测试的问题。首先,您应该检查函数是否返回true或false。如果返回的是真的,那么它是被发送的,但这可能是因为电子邮件在发送过程中被垃圾邮件拦截器截获,而从未到达收件人。我曾在我的一个网站上发生过这种情况,我们在那里向一位管理员发送了警告电子邮件,主题中有一个域名。托管公司的反垃圾邮件将我们的域名标记为垃圾邮件关键字,如果电子邮件中的任何地方包含域名,则不会发出任何电子邮件


我还从某个地方读到,发件人地址必须是真实的电子邮件地址。我从一个不存在的地址发送电子邮件,但可能并不总是有效

当您调用
mail()
SMTP服务器的响应是什么?您可以尝试将gmail地址切换到另一个吗?Gmail对PHP发送的电子邮件有一些问题——如果不悄悄地丢弃,它们通常会变成垃圾邮件。看看它是否适用于Yahoo/Hotmail/etc。@andrewsi:我用三个不同的电子邮件地址试用过:Gmail、Hotmail和我们的工作电子邮件。@keicea-好的。然后,下一步是检查
mail()
中的返回值。当你调用
mail()
它会返回什么?@David:我不确定。我没有访问服务器的权限。我把文件交给我们的IT部门,他们会上传。