2011-07-20 71 views
2

所以,我下載並安裝了smtp4dev。如何配置php.ini以使用smtp4dev?

當我嘗試在我的PHP文件發送郵件:

mail('localhost', "Hey there", "no"); 

我從php.ini中的錯誤,抱怨宣佈sendmail_from心不是。

我想它聲明:

sendmail_from = [email protected] 

這使得PHP的沉默,但仍然不起作用 - 嘗試加載網頁30秒,然後另一個錯誤。致命錯誤:超過30秒的最大執行時間。

我該如何配置php.ini才能正常工作?

的php.ini

[mail function] 
; For Win32 only. 
; http://php.net/smtp 
SMTP = localhost 
; http://php.net/smtp-port 
smtp_port = 25 

; For Win32 only. 
; http://php.net/sendmail-from 
;sendmail_from = [email protected] 

; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). 
; http://php.net/sendmail-path 
;sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 

; 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\apache\logs\php_mail.log" 

回答

1

我的猜測是,「sendmail_from」的錯誤發生,因爲即使你已經明確地在你的php.ini中定義它,你顯然是將其標記爲註釋(也就是說,在炭行的前面)

;sendmail_from = [email protected] 

我覺得應該是

sendmail_from = [email protected] 

這是不是真的正確的答案,但你也可能要檢查你的php.ini其他註釋標記=)

1

人,我只是修改了我這樣的代碼

[mail function] 
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury 
SMTP = localhost 
smtp_server = localhost 
smtp_port = 25 

看看這個視頻,幫助我 http://www.youtube.com/watch?v=IrYrI-ghxrE

+0

'smpt_server'? –

+0

我的意思是smtp_server,謝謝 –

+0

這個變量在'php.ini'中不存在。沒有'smtp_server'變量。正確的變量簡單地稱爲'SMTP'你的答案中已經提到了。 –