我無法使用PHP郵件()函數發送郵件。我收到一條錯誤消息。它有什麼問題?請幫我...我無法使用PHP郵件功能發送郵件...我收到錯誤
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in E:\xampp\htdocs\SimpleEmail.php on line 14
Email could not be sent.
<html>
<head>
<title>Simple Send Mail Form</title>
</head>
<body>
<h1>Mail Form</h1>
<form name="form1" method="post" action="SimpleEmail.php">
<table>
<tr><td><b>To</b></td><td><input type="text" name="mailto" size="35"></td></tr>
<tr><td><b>Subject</b></td>
<td><input type="text" name="mailsubject" size="35"></td></tr>
<tr><td><b>Message</b></td>
<td><textarea name="mailbody" cols="50" rows="7"></textarea></td>
</tr>
<tr><td colspan="2">
<input type="submit" name="Submit" value="Send">
</td>
</tr>
</table>
</form>
</body>
</html>
//SimpleEmail.php//
<?php
if (empty ($mailto)) {
die ("Recipient is blank! ") ;
}
if (empty ($mailsubject)){
$mailsubject=" " ;
}
if (empty ($mailbody)) {
$mailbody=" " ;
}
$result = mail ($mailto, $mailsubject, $mailbody) ;
if ($result) {
echo "Email sent successfully!" ;
}else{
echo "Email could not be sent." ;
}
?>
簡單,你沒有SMTP端口上運行的電子郵件服務器。您需要一個郵件功能才能發送電子郵件 –