提交表单时邮件不发送

时间:2013-11-16 17:16:22

标签: php forms email

由于某种原因,此表单不起作用,并且不通过提交表单发送电子邮件。它表示表单已成功提交,但它从未发送任何内容。是什么导致了这个问题?请帮忙。

    <?php
$id = protect($_GET['id']);
$sql = mysql_query("SELECT * FROM items WHERE id='$id'");
if(mysql_num_rows($sql)==0) { header("Location: $web[url]"); }
$row = mysql_fetch_array($sql);
?>
<section class="dashboard content">
    <div class="container">
            <div class="row">

                <div class="span12">
                    <h3>Contact with Owner</h3>
                    <?php
                    if(isset($_POST['do_send'])) {
                        $item_name = protect($_POST['item_name']);
                        $name = protect($_POST['name']);
                        $email = protect($_POST['email']);
                        $subject = protect($_POST['subject']);
                        $message = protect($_POST['message']);

                        if(empty($name) or empty($email) or empty($subject) or empty($message)) { echo error("All fields are required."); }
                        elseif(!isValidEmail($email)) { echo error("Please enter a valid email address."); }
                        else {
                                $get = mysql_fetch_array(mysql_query("SELECT * FROM admins ORDER BY id LIMIT 1"));
                                $admin_email = $get['email'];
                                $to = $admin_email;
                                $headers  = "From: $email\r\n"; 
                                $headers .= "Content-type: text/html\r\n"; 
                                $subjectt = $web[sitename].' - Message from '.$name;
                                $messaget = '<html><body><table border="0" cellspacing="2" cellpadding="2"><tr><td><span style="font-size:30px;font-weight:bold;">'.$web[sitename].'</span><br></td></tr><tr><td>You have new message from user for item. Here is message details:</td></tr><tr><td>From: '.$name.' ('.$email.')</td></tr><tr><td>Item: '.$row[name].'</td></tr><tr><td>Subject: '.$subject.'</td></tr><tr><td>Message:<br/>'.nl2br($message).'</td></tr></table></body></html>';
                                mail($to, $subjectt, $messaget, $headers);
                                echo success("Your message was sent successfully.");
                        }
                    }
                    ?>
                    <form action="" method="POST">
                            <div class="bg-color white rounded-top">
                                <div class="box-padding">
                                    <div class="control-group">
                                      <label class="control-label" for="inputUsername">Item</label>
                                      <div class="controls">
                                        <input type="text" id="inputUsername" name="item_name" class="input-block-level" disabled value="<?php echo $row['name']; ?>">
                                      </div>
                                    </div>
                                    <div class="control-group">
                                      <label class="control-label" for="inputUsername">Your name</label>
                                      <div class="controls">
                                        <input type="text" id="inputUsername" name="name" class="input-block-level">
                                      </div>
                                    </div>
                                    <div class="control-group">
                                      <label class="control-label" for="inputUsername">Your email address</label>
                                      <div class="controls">
                                        <input type="text" id="inputUsername" name="email" class="input-block-level">
                                      </div>
                                    </div>
                                    <div class="control-group">
                                      <label class="control-label" for="inputUsername">Subject</label>
                                      <div class="controls">
                                        <input type="text" id="inputUsername" name="subject" class="input-block-level">
                                      </div>
                                    </div>
                                    <div class="control-group">
                                      <label class="control-label" for="inputUsername">Message</label>
                                      <div class="controls">
                                        <textarea name="message" class="input-block-level" rows="4"></textarea>
                                      </div>
                                    </div>
                                </div>
                            </div>
                            <div class="bg-color dark-blue rounded-bottom">
                                <div class="box-padding narrow-horizontal">
                                    <div class="control-group">
                                      <div class="controls">
                                        <button type="submit" name="do_send" class="btn btn-primary">Send</button>
                                      </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                </div>

            </div>
    </div>
</section>

联系表格在这里:http://rocketraiser.com/contact/13546224#sthash.HnYyaGGz.0o0gQ4nS.dpbs

联系表格会带来单个项目名称。

请告诉我如何解决这个问题。非常感谢你。

-Harry

1 个答案:

答案 0 :(得分:0)

可能是表单没有操作,通过该代码的外观,操作应该与表单所在的URL相同