我没有收到来自php form / html的电子邮件。我是制作这些表单的新手,我想知道我哪里出错了。表单在活动站点上设置得很好,提交按钮会将我带回主页,这正是我想要的。谁能帮我弄清楚为什么我收不到这些邮件?
下面是html:
`
<section class="contact-container">
<div class="container mtb">
<div class="row">
<div class="col-md-8 wow fadeInLeft">
<h4>Get in touch</h4>
<hr>
<p>Leave a comment, review, or general musings.</p><br />
<form id="contact_form" action="websitehere" method="post">
<label>Name: <input class="textfield" name="name" type="text" value="" /></label>
<label>Email: <input class="textfield" name="email" type="text" value="" /></label>
<label>Message: <textarea class="textarea" cols="45" name="message" rows="5"></textarea></label>
<input class="button" name="submit" type="submit" value="Submit" />
</form>
</div>下面是PHP:
<?php
if (isset($_POST["submit"])) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$human = intval($_POST['human']);
$to = 'emailaddress@email.com';
$subject = 'Message for the author ';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
// Check if name has been entered
if (!$_POST['name']) {
$errName = 'Please enter your name';
}
// Check if email has been entered and is valid
if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$errEmail = 'Please enter a valid email address';
}
//Check if message has been entered
if (!$_POST['message']) {
$errMessage = 'Please enter your message';
}
//Check if simple anti-bot test is correct
if ($human !== 5) {
$errHuman = 'Your anti-spam is incorrect';
}
// If there are no errors, send the email
if (!$errName && !$errEmail && !$errMessage && !$errHuman) {
if (mail ($to, $subject, $body, $from)) {
$result='<div class="alert alert-success">Thank You! I will be in touch</div>';
} else {
$result='<div class="alert alert-danger">Sorry there was an error sending your message. Please try again later</div>';
}
}
}
?>发布于 2015-12-09 15:22:55
您在html代码中忘记了human。此外,请确保您没有将此电子邮件发送到雅虎电子邮件,因为自12月4日以来,他们的php邮件出现了问题。如果这还不能解决您的问题,这可能会对您有所帮助:http://email.about.com/od/emailprogrammingtips/qt/How_to_Send_Email_from_a_PHP_Script.htm
https://stackoverflow.com/questions/34170389
复制相似问题