在XAMPP for Linux中使用mailtodisk / mailoutput

时间:2013-10-15 23:41:38

标签: php linux xampp

与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 = me@example.com

; 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主页上看到“Mail”链接,用于测试默认邮件表单,因为它有很多像这样的崩溃:

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”?如果是的话,在我的情况下我需要做什么?

2 个答案:

答案 0 :(得分:7)

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

答案 1 :(得分:1)

Windows XAMPP用户:

扩展Lee Kowalkowski的出色解决方案:

1。创建新文件mailtodisk.php

我在C:\xampp\mailtodisk中创建了文件-请记住第3步

2。将Lee Kowalkowski's script(已完成路径的少量修改)粘贴到文件中:

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

根据需要更改$filename。对我来说,它在同一个驱动器中,所以/xampp正常工作。

3。打开php.ini (通常在C:\ xampp \ php中)并查找sendmail_path,注释现有的并粘贴以下内容:

sendmail_path="C:\xampp\php\php.exe C:\xampp\mailtodisk\mailtodisk.php"

确保php.exe路径正确,并且从步骤1开始到mailtodisk.php的路径。

重新启动Apache,您就完成了。

请注意,我使用的是Thunderbird,所以我个人使用的是.txt,而不是.eml(在第2步中),因此我可以直接查看电子邮件。

相关问题