试图发送一封没有显示任何错误信息或只是刷新它所显示的页面的邮件。
我试图通过电子邮件联系形式,但它不工作。这里是代码。尝试做回声,但它不工作。不显示任何错误以及。
联系方式:
<?php ob_start();
if(isset($_POST['submit'])) {
$to = "abc@gmail.com";
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$txt = $_POST['comment'];
$headers = "From: " .$email . "\r\n" .
"CC: xyz@gmail.com";
mail($to,$subject,$txt,$headers);
header("Location: contact.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>HMS System</title>
</head>
<body>
<div class="container">
<div class="page-header">
<h2>Contact Us Form</h2>
</div>
<form class="form-horizontal" action="contactus.php" method="post" role="form">
<div class="form-group">
<label for="name" class="col-sm-2 control-label">Name</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="name" placeholder="Insert your Name" id="name">
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label">Email Address</label>
<div class="col-sm-8">
<input type="email" class="form-control" name="email" placeholder="Email Address" id="email">
</div>
</div>
<div class="form-group">
<label for="subject" class="col-sm-2 control-label">Subject</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="subject" placeholder="Subject" id="subject">
</div>
</div>
<div class="form-group">
<label for="comments" class="col-sm-2 control-label">Comment</label>
<div class="col-sm-8">
<textarea class="form-control" rows="10" name="comment" style="resize:none;"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-8">
<input type="submit" value="Send Message" name="submit_contact" class="btn btn-block btn-danger" id="subject">
</div>
</div>
</form>
</section>
</article>
</div>
<div style="width:50px;height:50px;"></div>
</body>
3条答案
按热度按时间inb24sb21#
如果您是从您的本地服务器,您将不得不设置您的邮件正确的ini然后只有您将能够从您的本地机器发送邮件。
cgvd09ve2#
用这个
aiazj4mn3#
更好的方法是将
mail
语句中的函数。邮件正在返回bool
价值观。开始尽可能简单。验证是否从接收到所有值
$_POST
做