Use of mailtodisk / mailoutput in XAMPP for Linux

若如初见. 提交于 2019-12-06 07:21:42

问题


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

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:

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

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).

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.

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

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


回答1:


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);

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).

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).

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

sendmail_path=/opt/lampp/mailtodisk/mailtodisk

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

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



来源:https://stackoverflow.com/questions/19392975/use-of-mailtodisk-mailoutput-in-xampp-for-linux

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!