我是PHP新手,並以腳本爲例在線。 我已經安裝了Xampp,並且php已安裝並正在運行。 我試圖用hMailServer設置本地郵件服務器,但是我不完全確定它是否設置正確。 總之,這裏的PHP代碼:如何解決警告:mail()[function.mail]:SMTP服務器響應:530 SMTP認證是必需的。在C: xampp htdocs ..在線22錯誤
<?php
$subject="";
$detail="";
$customer_mail="";
$name="";
// Contact subject
$subject ="$subject";
// Details
$message="$detail";
// Mail of sender
$mail_from="$customer_mail";
// From
$header="from: $name <$mail_from>";
// Enter your email address
$to ='[email protected]';
$send_contact=mail($to,$subject,$message,$header);
// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>
以及相應的HTML代碼:
<table width="400" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td><strong>Contact Form </strong></td>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="form1" method="post" action="test.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td width="16%">Subject</td>
<td width="2%">:</td>
<td width="82%"><input name="subject" type="text" id="subject" size="50"></td>
</tr>
<tr>
<td>Detail</td>
<td>:</td>
<td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td>
</tr>
<tr>
<td>Name</td>
<td>:</td>
<td><input name="name" type="text" id="name" size="50"></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input name="customer_mail" type="text" id="customer_mail" size="50"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
當我提交表單我得到的錯誤警告:電子郵件()[function.mail]:SMTP服務器響應:530 SMTP認證是必需的。 任何想法可能是錯誤的? 謝謝
感謝您的快速響應,我已經使用郵件服務器的hMailServer,並嘗試使用谷歌郵件和本地但無濟於事。有關我應該用於Google郵件的設置的任何建議? – 2012-07-09 11:34:54
請參閱http://effectivewebdesigns.blogspot.de/2010/09/smtp-from-xampp-on-localhost-using-your.html – worenga 2012-07-09 11:54:12
試圖按照本教程設法修改之前完成的php.ini 。但是,在sendmail文件中將更改放在哪裏並不是很明顯。你有什麼想法把它放在哪裏? – 2012-07-09 12:20:54