我正在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