我不知道我的代码有什么问题,我认为它应该可以工作,但由于某种原因,当我在 chrome 上查看 php 文件并按下“提交”时 - 它显示“警告:mail() [function.mail ]:无法在“localhost”端口 25 连接到邮件服务器,验证 php.ini 中的“SMTP”和“smtp_port”设置或在第 27 行的 C:\xampp\htdocs\BumblebeeNursery\send_contact.php 中使用 ini_set() '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 = "alisarraff5@hotmail.com";
$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>
有人可以帮帮我吗,我正要扯掉我的头发。先感谢您