可能重複:
Failed to connect to mailserver at 「localhost」 port 25PHP聯繫表單無效 - 代碼有什麼問題?
我不知道什麼是錯我的代碼,我認爲它應該工作,但由於某些原因,當我認爲對鉻的PHP文件當我按'提交' - 它說:「警告:郵件()[函數。郵件]:無法連接到郵件服務器在」本地主機「端口25,驗證您的」SMTP「和」smtp_port「設置在php.ini或使用的ini_set()在C:\ XAMPP \ htdocs中\ BumblebeeNursery \ send_contact.php第27" 行 的「send_contact.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="../../../Users/Ali/Documents/Dreamweaver/individual/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Message: $message <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$formcontent="From: $name \n Message: $message";
$recipient = "[email protected]";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader);
echo "Thank You!";
?>
?>
</body>
</html>
和接觸:
<form action="send_contact.php" method="POST">
<table width="400" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="29%" class="bodytext">Your name:</td>
<td width="71%"><input name="name" type="text" id="name" size="32"></td>
</tr>
<tr>
<td class="bodytext">Email address:</td>
<td><input name="email" type="text" id="email" size="32"></td>
</tr>
<tr>
<td class="bodytext">Comments:</td>
<td><textarea name="message" cols="45" rows="6" id="comment" class="bodytext"> </textarea></td>
</tr>
<tr>
<td class="bodytext"> </td>
<td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td>
</tr>
</table>
</form>
可能有人請幫助我,我要撕裂我的頭髮了。 預先感謝您
找不到您的郵件服務器。你需要檢查PHP的配置。 – andrewsi
在windows **上的PHP要求你在你之前配置php.ini中的['SMTP'](http://www.php.net/manual/en/mail.configuration.php#ini.smtp)「選項能夠發送郵件。 – DaveRandom
[如何從XAMPP發送電子郵件(PHP)(http://expertester.wordpress.com/2010/07/07/how-to-send-email-from-xampp-php/) –