我已經寫了一小塊的PHP代碼發送郵件:無法連接到郵件服務器在PHP
<?php
//define the receiver of the email
$to = '[email protected]';
//define the subject of the email
$subject = 'Hishob email';
//define the message to be sent. Each line should be separated with \n
$message = "Hello World!\n\nThis is my first mail.";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: [email protected]\r\nReply-To: [email protected]";
//send the email
$mail_sent = mail($to, $subject, $message, $headers);
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
執行它後,我得到了以下警告:
無法連接到郵件服務器在「localhost」端口25上,在php.ini中驗證您的「SMTP」和「smtp_port」設置或在第11行的C:\ wamp \ www \ NewHishob \ PhpFiles \ send_mail.php中使用ini_set()
郵件失敗
我正在使用WAMP服務器,並且有兩個文件,INI-DIST和其他INI-RECOMENDED。哪一個很重要?
我也通過的php.ini-dist的文件不見了,用於SMTP它包含以下內容:
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
;sendmail_from = [email protected]
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
請建議我應該怎麼辦呢?感謝所有提前。
WAMP不是服務器。 WAMP是Windows,Apache2 webserver,MySQL dbms和PHP腳本引擎組合的「代號」。 – 2011-01-22 15:19:14