请协助我的PHP表单。在这篇文章之后,我既有我的HTML表单,也有我的PHP页面。当我尝试在我的网站上使用该表单时,我没有收到电子邮件。我已经验证我的电子邮件地址正常,这应该不是问题。
以下是我的HTML表单:
<!-- Contact Form -->
<div class="col-md-6 col-sm-6">
<hr>
<p>Have a question or comment? Fill out the form below.</p>
<div class="contact-form wow fadeInLeft showdelay2">
<form name="sentMessage" id="contactForm" novalidate>
<div class="control-group form-group">
<div class="controls">
<label>Name</label>
<input type="text" class="form-control dark" id="name" placeholder="Name" required data-validation-required-message="Please enter your name.">
<p class="help-block"></p>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Email</label>
<input type="email" class="form-control dark" id="email" placeholder="Email Address" required data-validation-required-message="Please enter your email address.">
<p class="help-block"></p>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Message</label>
<textarea class="form-control dark" rows="7" id="message" placeholder="Message" required data-validation-required-message="Please enter your message" maxlength="999" style="resize:none"></textarea>
<p class="help-block"></p>
</div>
</div>
<div id="success"></div>
<div class="pull-right">
<button type="submit" class="btn btn-info btn-lg">Submit</button>
</div>
</form>
<div class="clearfix"></div>
</div>
</div>
<!-- ./contact form -->
以下代码是我的contact_me.php页面,该页面似乎无效。
<?php
// check if fields passed are empty
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];
// create email body and send it
$to = 'email@addresss.com'; 'email@address.com'; // PUT YOUR EMAIL ADDRESS HERE
$email_subject = "Contact form from: $name"; // EDIT THE EMAIL SUBJECT LINE HERE
$email_body = "You have received a new message from your website's contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nMessage:\n$message";
$headers = "From: info@bootstrapwizard.info\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
答案 0 :(得分:1)
您的字符串不正确,有效格式为:
$to = 'AdrianPham@crosshatcheatery.com,Webmaster@crosshatcheatery.com';
标题应以"\r\n"
$headers = "From: info@bootstrapwizard.info\r\n";
$headers .= "Reply-To: $email_address";