在 XAMPP for Linux 中使用 mailtodisk/mailoutput

2024-04-12php开发问题
2

本文介绍了在 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17