2013-10-15 46 views
3

與Windows不同,我在Linux中使用「mailtodisk」PHP選項時遇到了麻煩。看起來它甚至不存在。在XAMPP for Linux中使用mailtodisk/mailoutput

在「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 = 

; 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=On 

; Log all mail() calls including the full path of the script, line #, to address and headers 
mail.log ="/opt/lampp/logs/php_mail_log" 

[SQL] 

我看不到在本地主機主頁上的「郵件」鏈接,用於測試的默認郵件形式,因爲它與許多崩潰這樣的一個人:

Notice: Undefined variable: TEXT in /opt/lampp/htdocs/xampp/start.php on line 12

觀測數據:儘管在本地主機網頁這樣的錯誤,我跑項目,沒有問題。

事實上,它似乎沒有菜單中的「郵件」鏈接(我搜索了源代碼)。

我不知道此信息是否有幫助,但「sendmail.php」文件使用的文件不存在於我的系統中:/usr/sbin/sendmail

當前版本的XAMPP是:1.8.3,並且最近已更新。

是否可以在XAMPP for Linux中使用「mailtodisk」?如果是的話,我需要在我的情況下做什麼?

+0

我想說linux會帶來所有需要的工具來將郵件發送到本地硬盤,但這需要知道如何配置郵件服務器。除非「mailtodisk」也作爲linux的可執行文件出現,否則似乎此功能僅適用於Windows。 XAMPP傢伙應該知道更多 - 你是否在那裏要求支持? – Sven

+0

還沒有。謝謝。 –

回答

5

它不存在,但是這是我的mailtodisk腳本:

的/ opt/LAMPP/mailtodisk/mailtodisk:

#!/opt/lampp/bin/php 
<?php 
$input = file_get_contents('php://stdin'); 
$filename = '/opt/lampp/mailoutput/mail-' . gmdate('Ymd-Hi-s') . '.txt'; 
$retry = 0; 
while(is_file($filename)) 
{ 
    $filename = '/opt/lampp/mailoutput/mail-' . gmdate('Ymd-Hi-s') . '-' . ++$retry . '.txt'; 
} 
file_put_contents($filename, $input); 

您的XAMPP安裝可能不是文件夾/opt/lampp中,如果不是,則需要編輯該腳本(儘管它不必位於XAMPP文件夾中)。

確保您mailtodisk腳本可以被任何人(chmod 755 mailtodisk)上運行,並且您mailoutput文件夾可以由任何人(chmod 777 mailoutput)被寫入。

然後php.ini文件(/opt/lampp/etc/php.ini)應具有:

sendmail_path=/opt/lampp/mailtodisk/mailtodisk 

任何時候你編輯php.ini文件,你必須重新啓動Apache。

如果您不想發送電子郵件,則安裝sendmail會過度。