1
我正嘗試使用PHP發送簡單郵件。我試圖用telnet來檢查水星是否在運行,並回答是。此外,mail()返回true,因此我的腳本應該沒問題,但是郵件仍然無法發送,這可能是導致此問題的原因?即使SMTP服務器正在運行並且PHP郵件()返回true,郵件也無法在PHP中傳遞
這是我的PHP代碼:
$subject = "Simple mail";
$message = "Here is a test mail";
$to = "[email protected]";
$from = "[email protected]";
$header = "From: ".$from;
if(mail($to, $subject, $message, $header))
print "success<br>";
else
print "fail<br>";
下面是我的php.ini:
[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
; SMTP = localhost
; smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = [email protected]
; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesC:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
;sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder
sendmail_path = "C:\mailtodisk\mailtodisk.exe"
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off
; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log = "C:\xampp\php\logs\php_mail.log"
因此,如果郵件服務器運行正常,並且腳本是正確的,那麼唯一的問題導致郵件無法發送應該是郵件從未到達服務器,那麼我能做些什麼來找出錯誤在哪裏並解決它?
我已按照重要通知進行了一些更改。
第一件事是檢查SMTP服務器的日誌... – arkascha 2012-07-25 08:10:12
牛逼20120725 161556 501017fa從127.0.0.1 牛逼20120725連接161557 501017fa 牛逼20120725 161627 501017fa連接關閉與127.0.0.1,31秒。過去。 我只是看到這條消息,但找不到重要的'郵件發送'和'收件人'命令 – Conrad 2012-07-25 08:18:33
我不知道爲什麼,有時它甚至沒有任何修改日誌文件,所以它看起來像郵件甚至沒有達到服務器的所有 – Conrad 2012-07-25 08:21:43