Skip to content

Instantly share code, notes, and snippets.

@adnan360
Last active September 1, 2019 02:25
Show Gist options
  • Save adnan360/068d82dac94cc7a09da3a7340997e4cd to your computer and use it in GitHub Desktop.
Save adnan360/068d82dac94cc7a09da3a7340997e4cd to your computer and use it in GitHub Desktop.
Use of mailtodisk / mailoutput in XAMPP for Linux

// http://stackoverflow.com/a/23048315

// by Lee Kowalkowski

First run:

sudo mkdir /opt/lampp/mailtodisk

sudo mkdir /opt/lampp/mailoutput

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

Also,

sudo chmod +x /opt/lampp/mailtodisk/mailtodisk

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment