我正在HTML中创建单页面应用程序。我是PHP新手。在那我有一个留言页面。我有文本框输入名称和电子邮件。我有按钮,而点击按钮邮件将发送给用户。我正在用PHP编写电子邮件代码。电子邮件不发送在PHP
我的代码是
HTML代码
<div class="coment-form">
<h4>LEAVE YOUR COMMENT</h4>
<form class="form" id='form' name='form' method="post" action="service.php">
<input type="text" name="name" value="Name :" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Name :';}" required="">
<input type="email" name="email" value="Email (will not be published)* :" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email (will not be published)* :';}" required="">
<input type="text" name="cmt" value="Website :" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Website :';}" required="">
<textarea type="text" name="message" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Your Comment...';}" required="">Your Comment...</textarea>
<input type="submit" value="Submit Comment" >
</form>
</div>
PHP代码:
service.php文件,同时单击按钮
<?php
include('config.php');
$name=$_POST['name'];
$email=$_POST['email'];
$cmt = $_POST['cmt'];
$message=$_POST['message'];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
//mail code
$to = $_POST['email'];
$email_subject = "Dear $name";
$email_body = "Thank you for inquiring about our Services advertised on our webSite.
Each of the listed services we offer are uniquely different.
One of our representatives will contact you soon, would help and appreciate if you can drop a line with a suitable
Date and Time for a Phone/Skype discussion.
Once again, thank you for your interest in our services.
Cordially,
".
//mail code
// $email_to = "[email protected]";
$email_to = "[email protected]";
$email_sub = "Enquiry from contact us form";
$email_bod =
"$name
".
$headers = "From:[email protected]";
mail($to,$email_subject,$email_body,$headers);
mail($email_to,$email_sub,$email_bod,$headers);
echo '<script type="text/javascript">alert("Thank you admin will contact you soon...!");window.location.assign("Contact_us.html");</script>';
//header('Location: contact.php');
?>
我的问题是电子邮件不发送。
我在我的机器上安装了WaMp。它是橙色,同时检查,我得到一个错误
你的端口80实际使用
服务器:Microsoft-IIS/7.5 有什么办法来纠正这个错误?
谁能帮我
你在行尾有两个点('.')。 '.'旨在连接字符串。 –
你正在使用本地服务器(xampp,wampp等)或在线服务器 – deemi
请查看http://php.net/manual/en/mail.configuration.php – Robert