与Windows不同,我在Linux中无法使用“mailtodisk” PHP选项。看起来它根本不存在。

在“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]

我无法在localhost主页上看到“邮件”链接,以测试默认的邮件格式,因为它像这样的崩溃很多:
Notice: Undefined variable: TEXT in /opt/lampp/htdocs/xampp/start.php on line 12
Obs:尽管在localhost主页中出现此错误,但我运行的项目没有问题。

实际上,它似乎在菜单中没有“邮件”链接(我已经搜索了源代码)。

我不知道此信息是否有任何帮助,但是文件“sendmail.php”使用的文件在我的系统中不存在:/usr/sbin/sendmail

XAMPP的当前版本为:1.8.3,最近更新。

可以在XAMPP for Linux中使用“mailtodisk”吗?如果是,我在这种情况下需要做什么?

最佳答案

它不存在,但这是我的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实在是太过分了。

10-08 16:38