沃梦达 / 编程问答 / php问题 / 正文

在 XAMPP for Linux 中使用 mailtodisk/mailoutput

Use of mailtodisk / mailoutput in XAMPP for Linux(在 XAMPP for Linux 中使用 mailtodisk/mailoutput)

本文介绍了在 XAMPP for Linux 中使用 mailtodisk/mailoutput的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与 Windows 不同,我无法在 Linux 中使用mailtodisk"PHP 选项.好像根本不存在.

Unlike in Windows, i'm having trouble to use the "mailtodisk" PHP option in Linux. Looks like it doesn't even exist.

在php.ini"的邮件部分,没有对它的引用:

In "php.ini", in the mail section, there is no reference to it:

[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]

我在本地主机主页中看不到邮件"链接,用于测试默认邮件表单,因为它有很多像这样的崩溃:

I can't see the "Mail" link in the localhost homepage, for test the default mail form, because it's with many crashes like this one:

注意:未定义变量:/opt/lampp/htdocs/xampp/start.php 第 12 行中的 TEXT

Obs:尽管 localhost 主页中出现此错误,但我正在运行项目没有问题.

Obs: despite this errors in the localhost homepage, i'm running projects without a problem.

实际上,它的菜单中似乎没有邮件"链接(我已经搜索了源代码).

In fact, it doesn't seems to have a "Mail" link in the menu (i've searched the source code).

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

I don't know if this info helps in any way, but the file "sendmail.php" uses a file that doesn't exist in my system: /usr/sbin/sendmail.

XAMPP 的当前版本是:1.8.3,最近更新了.

The current version of XAMPP is: 1.8.3, and was recently updated.

是否可以在 XAMPP for Linux 中使用mailtodisk"?如果是,我需要在我的情况下做什么?

Is it possible to use "mailtodisk" in XAMPP for Linux? If yes, what i need to do in my situation?

推荐答案

不存在,但这是我的mailtodisk脚本:

It doesn't exist, but this is my mailtodisk script:

/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 中文件夹).

Your XAMPP installation might not be in the folder /opt/lampp, if it isn't, you'll need to edit the script (although it doesn't have to live in the XAMPP folder).

确保您的 mailtodisk 脚本可以由任何人运行(chmod 755 mailtodisk),并且您的 mailoutput 文件夹可以被任何人写入(chmod 777 邮件输出).

Make sure your mailtodisk script can be run by anybody (chmod 755 mailtodisk), and your mailoutput folder can be written to by anybody (chmod 777 mailoutput).

那么你的 php.ini 文件(/opt/lampp/etc/php.ini)应该有:

Then your php.ini file (/opt/lampp/etc/php.ini) should have:

sendmail_path=/opt/lampp/mailtodisk/mailtodisk

每次编辑 php.ini 文件时,都必须重新启动 Apache.

Any time you edit the php.ini file, you have to restart Apache.

如果您不想发送电子邮件,安装 sendmail 是多余的.

Installing sendmail if you don't want to send the emails, is overkill.

这篇关于在 XAMPP for Linux 中使用 mailtodisk/mailoutput的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在 XAMPP for Linux 中使用 mailtodisk/mailoutput

基础教程推荐