可能重复:
Failed to connect to mailserver at “localhost” port 25
我不知道我的代码有什么问题,我认为它应该可以工作但是出于某种原因,当我在chrome上查看php文件时,当我按下'submit'时 - 它说“Warning:mail()[ function.mail]:无法连接到“localhost”端口25的邮件服务器,验证php.ini中的“SMTP”和“smtp_port”设置,或者使用C:\ xampp \ htdocs \ BumblebeeNursery \ send_contact.php中的ini_set()第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 = "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>
有人可以帮助我,我即将撕掉我的头发。 提前谢谢
答案 0 :(得分:0)
您无法从本地主机发送电子邮件,而应通过域服务器上的真实网站发送电子邮件。